Skip to content

Commit ef66314

Browse files
committed
test(@angular/build): add test with 'vitest' import in browser mode
Closes angular#31745 Actually closed by angular#31781
1 parent 1ef24a7 commit ef66314

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import assert from 'node:assert/strict';
2+
import { writeFile } from '../../utils/fs';
3+
import { installPackage } from '../../utils/packages';
4+
import { exec, ng } from '../../utils/process';
5+
import { applyVitestBuilder } from '../../utils/vitest';
6+
7+
/**
8+
* Allow `vitest` import in browser mode.
9+
* @see https://github.com/angular/angular-cli/issues/31745
10+
*/
11+
export default async function (): Promise<void> {
12+
await applyVitestBuilder();
13+
14+
await installPackage('playwright@1');
15+
await installPackage('@vitest/browser-playwright@4');
16+
17+
await exec('npx', 'playwright', 'install', 'chromium', '--only-shell');
18+
19+
await writeFile(
20+
'src/app/app.spec.ts',
21+
`
22+
import { test, expect } from 'vitest';
23+
24+
test('should pass', () => {
25+
expect(true).toBe(true);
26+
});
27+
`,
28+
);
29+
30+
const { stdout } = await ng('test', '--browsers', 'ChromiumHeadless');
31+
32+
assert.match(stdout, /1 passed/, 'Expected 1 tests to pass.');
33+
}

0 commit comments

Comments
 (0)