Skip to content

Commit

Permalink
test: enable test cases in .spec.ts (#698)
Browse files Browse the repository at this point in the history
  • Loading branch information
LingyuCoder authored Jan 14, 2025
1 parent dd16481 commit 473be32
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 759 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,7 @@ exports[`module graph transform from stats > module type === from origin 1`] = `
},
],
"exports": [],
"layers": [],
"moduleGraphModules": [],
"modules": [
{
Expand All @@ -884,6 +885,7 @@ exports[`module graph transform from stats > module type === from origin 1`] = `
"isPreferSource": false,
"kind": 0,
"path": "/Users/demo/node_modules/@angular/common/fesm2022/common.mjs",
"renderId": undefined,
"size": {
"parsedSize": 0,
"sourceSize": 267758,
Expand All @@ -903,6 +905,7 @@ exports[`module graph transform from stats > module type === from origin 1`] = `
"isPreferSource": false,
"kind": 0,
"path": "/Users/demo/node_modules/@angular/common/fesm2022/http.mjs",
"renderId": undefined,
"size": {
"parsedSize": 0,
"sourceSize": 94775,
Expand All @@ -923,6 +926,7 @@ exports[`module graph transform from stats > module type === from origin 1`] = `
"isPreferSource": false,
"kind": 0,
"path": "/Users/demo/node_modules/@angular/platform-browser/fesm2022/platform-browser.mjs",
"renderId": undefined,
"size": {
"parsedSize": 0,
"sourceSize": 76943,
Expand All @@ -941,6 +945,7 @@ exports[`module graph transform from stats > module type === from origin 1`] = `
"isPreferSource": false,
"kind": 0,
"path": "/Users/demo/node_modules/@angular/router/fesm2022/router.mjs",
"renderId": undefined,
"size": {
"parsedSize": 0,
"sourceSize": 268651,
Expand All @@ -963,7 +968,7 @@ exports[`module graph transform from stats > normal module in multi concatenatio
"kind": 1,
"module": 2,
"originDependency": 3,
"request": "./common",
"request": "common",
"resolvedRequest": "common.js",
"statements": [
{
Expand All @@ -989,7 +994,7 @@ exports[`module graph transform from stats > normal module in multi concatenatio
"kind": 1,
"module": 5,
"originDependency": 3,
"request": "./common",
"request": "common",
"resolvedRequest": "common.js",
"statements": [
{
Expand All @@ -1011,6 +1016,7 @@ exports[`module graph transform from stats > normal module in multi concatenatio
},
],
"exports": [],
"layers": [],
"moduleGraphModules": [],
"modules": [
{
Expand All @@ -1028,16 +1034,19 @@ exports[`module graph transform from stats > normal module in multi concatenatio
3,
],
"path": "entry1.js",
"renderId": undefined,
"rootModule": 2,
"size": {
"parsedSize": 0,
"sourceSize": 162,
"transformedSize": 162,
"parsedSize": -1,
"sourceSize": -1,
"transformedSize": -1,
},
"webpackId": "",
},
{
"chunks": [],
"chunks": [
"0",
],
"concatenationModules": [
1,
],
Expand All @@ -1050,15 +1059,19 @@ exports[`module graph transform from stats > normal module in multi concatenatio
"isPreferSource": false,
"kind": 0,
"path": "entry1.js",
"renderId": undefined,
"size": {
"parsedSize": 0,
"sourceSize": 78,
"transformedSize": 78,
"parsedSize": -1,
"sourceSize": -1,
"transformedSize": -1,
},
"webpackId": "",
},
{
"chunks": [],
"chunks": [
"0",
"1",
],
"concatenationModules": [
1,
4,
Expand All @@ -1072,10 +1085,11 @@ exports[`module graph transform from stats > normal module in multi concatenatio
"isPreferSource": false,
"kind": 0,
"path": "common.js",
"renderId": undefined,
"size": {
"parsedSize": 0,
"sourceSize": 84,
"transformedSize": 84,
"parsedSize": -1,
"sourceSize": -1,
"transformedSize": -1,
},
"webpackId": "",
},
Expand All @@ -1094,16 +1108,19 @@ exports[`module graph transform from stats > normal module in multi concatenatio
3,
],
"path": "entry2.js",
"renderId": "1",
"rootModule": 5,
"size": {
"parsedSize": 0,
"sourceSize": 162,
"transformedSize": 162,
"parsedSize": -1,
"sourceSize": -1,
"transformedSize": -1,
},
"webpackId": "",
},
{
"chunks": [],
"chunks": [
"1",
],
"concatenationModules": [
4,
],
Expand All @@ -1116,10 +1133,11 @@ exports[`module graph transform from stats > normal module in multi concatenatio
"isPreferSource": false,
"kind": 0,
"path": "entry2.js",
"renderId": undefined,
"size": {
"parsedSize": 0,
"sourceSize": 78,
"transformedSize": 78,
"parsedSize": -1,
"sourceSize": -1,
"transformedSize": -1,
},
"webpackId": "",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ModuleGraph } from '@/build-utils/common';
import { Chunks } from '@/build-utils/build';
import { removeAbsModulePath } from '../utils';
import { compileByWebpack5 } from '@scripts/test-helper';
import type { Plugin } from '@rsdoctor/types';

const resolveFixture = (...paths: string[]) => {
return path.resolve(__dirname, '../../fixtures', ...paths);
Expand All @@ -13,7 +14,7 @@ const resolveFixture = (...paths: string[]) => {
describe('module graph transform from stats', () => {
it('normal module in multi concatenation module', async () => {
const fixtureName = 'normal-module-in-multi-concatenation';
const stats = await compileByWebpack5(
const stats = (await compileByWebpack5(
{
entry1: resolveFixture(fixtureName, 'entry1'),
entry2: resolveFixture(fixtureName, 'entry2'),
Expand All @@ -25,7 +26,7 @@ describe('module graph transform from stats', () => {
chunkFilename: '[name].js',
},
},
);
)) as Plugin.StatsCompilation;

const chunkGraph = Chunks.chunkTransform(new Map(), stats);

Expand All @@ -42,7 +43,13 @@ describe('module graph transform from stats', () => {
const graphData = graph.toData();
expect(graphData.modules[0].webpackId.length).toBeTruthy();

graphData.modules.forEach((mod) => (mod.webpackId = ''));
graphData.modules.forEach((mod) => {
// prevent ci failed on win32
mod.webpackId = '';
mod.size.sourceSize = -1;
mod.size.transformedSize = -1;
mod.size.parsedSize = -1;
});
expect(graphData).toMatchSnapshot();
});

Expand Down
Loading

0 comments on commit 473be32

Please sign in to comment.