Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): use concurrent instead of serial for globContentJSON #2170

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 15 additions & 10 deletions e2e/cases/performance/load-resource/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ test('should generate prefetch link when prefetch is defined', async () => {

const files = await rsbuild.unwrapOutputJSON();

const asyncFileName = Object.keys(files).find((file) =>
file.includes('/static/js/async/'),
const asyncFileName = Object.keys(files).find(
(file) =>
file.includes('/static/js/async/') && !file.endsWith('.LICENSE.txt'),
)!;
const [, content] = Object.entries(files).find(([name]) =>
name.endsWith('.html'),
Expand Down Expand Up @@ -66,8 +67,9 @@ test('should generate prefetch link correctly when assetPrefix do not have a pro

const files = await rsbuild.unwrapOutputJSON();

const asyncFileName = Object.keys(files).find((file) =>
file.includes('/static/js/async/'),
const asyncFileName = Object.keys(files).find(
(file) =>
file.includes('/static/js/async/') && !file.endsWith('.LICENSE.txt'),
)!;
const [, content] = Object.entries(files).find(([name]) =>
name.endsWith('.html'),
Expand Down Expand Up @@ -187,8 +189,9 @@ test('should generate preload link when preload is defined', async () => {

const files = await rsbuild.unwrapOutputJSON();

const asyncFileName = Object.keys(files).find((file) =>
file.includes('/static/js/async/'),
const asyncFileName = Object.keys(files).find(
(file) =>
file.includes('/static/js/async/') && !file.endsWith('.LICENSE.txt'),
)!;
const [, content] = Object.entries(files).find(([name]) =>
name.endsWith('.html'),
Expand Down Expand Up @@ -230,8 +233,9 @@ test('should generate preload link with crossOrigin', async () => {

const files = await rsbuild.unwrapOutputJSON();

const asyncFileName = Object.keys(files).find((file) =>
file.includes('/static/js/async/'),
const asyncFileName = Object.keys(files).find(
(file) =>
file.includes('/static/js/async/') && !file.endsWith('.LICENSE.txt'),
)!;
const [, content] = Object.entries(files).find(([name]) =>
name.endsWith('.html'),
Expand Down Expand Up @@ -270,8 +274,9 @@ test('should generate preload link without crossOrigin when same origin', async

const files = await rsbuild.unwrapOutputJSON();

const asyncFileName = Object.keys(files).find((file) =>
file.includes('/static/js/async/'),
const asyncFileName = Object.keys(files).find(
(file) =>
file.includes('/static/js/async/') && !file.endsWith('.LICENSE.txt'),
)!;
const [, content] = Object.entries(files).find(([name]) =>
name.endsWith('.html'),
Expand Down
6 changes: 4 additions & 2 deletions e2e/cases/source/alias-by-target/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ test('should allow to set alias by build target', async () => {
const files = await rsbuild.unwrapOutputJSON();
const fileNames = Object.keys(files);
const webIndex = fileNames.find(
(file) => file.includes('static/js') && file.includes('index.js'),
(file) => file.includes('static/js') && file.endsWith('index.js'),
);
const nodeIndex = fileNames.find(
(file) => file.includes('server/index') && file.endsWith('index.js'),
);
const nodeIndex = fileNames.find((file) => file.includes('server/index'));

expect(files[webIndex!]).toContain('for web target');
expect(files[nodeIndex!]).toContain('for node target');
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/source/multiple-entry/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test('should allow to set entry by build target', async () => {
const files = await rsbuild.unwrapOutputJSON();
const fileNames = Object.keys(files);
const webIndex = fileNames.find(
(file) => file.includes('static/js') && file.includes('index.js'),
(file) => file.includes('static/js') && file.endsWith('index.js'),
);
const nodeIndex = fileNames.find((file) => file.includes('server/index'));

Expand Down
10 changes: 7 additions & 3 deletions e2e/scripts/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ export const globContentJSON = async (path: string, options?: GlobOptions) => {
const files = await glob(convertPath(join(path, '**/*')), options);
const ret: Record<string, string> = {};

for await (const file of files) {
ret[file] = await fse.readFile(file, 'utf-8');
}
await Promise.all(
files.map((file) =>
fse.readFile(file, 'utf-8').then((content) => {
ret[file] = content;
}),
),
);

return ret;
};
Expand Down