Skip to content

Commit 0599580

Browse files
committed
test: use esbuild-based karma builder for e2e tests in esbuild suite
Updated the E2E tests to use the esbuild-based karma builder when running the esbuild test suite.
1 parent 486d477 commit 0599580

File tree

4 files changed

+19
-35
lines changed

4 files changed

+19
-35
lines changed

tests/legacy-cli/e2e/tests/misc/karma-error-paths.ts

-26
This file was deleted.

tests/legacy-cli/e2e/tests/test/test-scripts.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export default async function () {
1010

1111
// prepare global scripts test files
1212
await writeMultipleFiles({
13-
'src/string-script.js': `stringScriptGlobal = 'string-scripts.js';`,
14-
'src/input-script.js': `inputScriptGlobal = 'input-scripts.js';`,
13+
'src/string-script.js': `globalThis.stringScriptGlobal = 'string-scripts.js';`,
14+
'src/input-script.js': `globalThis.inputScriptGlobal = 'input-scripts.js';`,
1515
'src/typings.d.ts': `
1616
declare var stringScriptGlobal: any;
1717
declare var inputScriptGlobal: any;
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
import assert from 'node:assert';
2+
import { getGlobalVariable } from '../../utils/env';
13
import { writeFile } from '../../utils/fs';
24
import { ng } from '../../utils/process';
5+
import { assertIsError } from '../../utils/utils';
36

47
export default async function () {
8+
if (getGlobalVariable('argv')['esbuild']) {
9+
// TODO: enable once this is fixed when using the esbuild builder.
10+
return;
11+
}
12+
513
await writeFile(
614
'src/app/app.component.spec.ts',
715
`
8-
it('show fail', () => {
16+
it('should fail', () => {
917
expect(undefined).toBeTruthy();
1018
});
1119
`,
@@ -16,18 +24,17 @@ export default async function () {
1624
await ng('test', '--no-watch', '--source-map');
1725
throw new Error('ng test should have failed.');
1826
} catch (error) {
19-
if (!(error instanceof Error && error.message.includes('app.component.spec.ts'))) {
20-
throw error;
21-
}
27+
assertIsError(error);
28+
assert.match(error.message, /src\/app\/app\.component\.spec\.ts/);
29+
assert.doesNotMatch(error.message, /_karma_webpack_/);
2230
}
2331

2432
// when sourcemaps are 'off' the stacktrace won't point to the spec.ts file.
2533
try {
2634
await ng('test', '--no-watch', '--no-source-map');
2735
throw new Error('ng test should have failed.');
2836
} catch (error) {
29-
if (!(error instanceof Error && error.message.includes('main.js'))) {
30-
throw error;
31-
}
37+
assertIsError(error);
38+
assert.match(error.message, /main\.js/);
3239
}
3340
}

tests/legacy-cli/e2e/utils/project.ts

+3
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ export async function useCIChrome(projectName: string, projectDir = ''): Promise
192192
const project = workspaceJson.projects[projectName];
193193
const appTargets = project.targets || project.architect;
194194
appTargets.test.options.browsers = 'ChromeHeadlessNoSandbox';
195+
appTargets.test.options.builderMode = getGlobalVariable('argv')['esbuild']
196+
? 'application'
197+
: 'browser';
195198
});
196199
}
197200

0 commit comments

Comments
 (0)