Skip to content

Commit

Permalink
chore: use node test runner (puppeteer#11574)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightning00Blade authored Jan 3, 2024
1 parent 613f716 commit 16becdb
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 67 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ jobs:
run: |
npm run unit -w puppeteer-core -w puppeteer --if-present
ng-schematics-tests:
ng-schematics-unit:
name: '[Required] Angular Schematics tests'
runs-on: ubuntu-latest
needs: check-changes
Expand All @@ -445,7 +445,7 @@ jobs:
env:
PUPPETEER_SKIP_DOWNLOAD: true
- name: Run tests
run: npm run test --workspace @puppeteer/ng-schematics
run: npm run unit --workspace @puppeteer/ng-schematics

ng-schematics-smoke-tests:
name: Angular Schematics smoke tests on ${{ matrix.os }}
Expand Down
10 changes: 1 addition & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/browsers/test/src/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

export const testChromeBuildId = '113.0.5672.0';
export const testChromiumBuildId = '1083080';
export const testFirefoxBuildId = '122.0a1';
export const testFirefoxBuildId = '123.0a1';
export const testChromeDriverBuildId = '115.0.5763.0';
export const testChromeHeadlessShellBuildId = '118.0.5950.0';
14 changes: 6 additions & 8 deletions packages/ng-schematics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"clean": "../../tools/clean.js",
"dev:test": "npm run test --watch",
"dev": "npm run build --watch",
"test": "wireit"
"unit": "wireit"
},
"wireit": {
"build": {
"command": "tsc -b && node tools/copySchemaFiles.js",
"command": "tsc -b && node tools/copySchemaFiles.mjs",
"clean": "if-file-deleted",
"files": [
"tsconfig.json",
"tsconfig.spec.json",
"tsconfig.test.json",
"src/**",
"test/src/**"
],
Expand All @@ -25,8 +25,8 @@
"*.tsbuildinfo"
]
},
"test": {
"command": "mocha",
"unit": {
"command": "node --test --test-reporter spec test/build",
"dependencies": [
"build"
]
Expand All @@ -52,10 +52,8 @@
"@angular-devkit/schematics": "^17.0.7"
},
"devDependencies": {
"@types/node": "^16.18.61",
"@schematics/angular": "^17.0.7",
"@angular/cli": "^17.0.7",
"rxjs": "7.8.1"
"@angular/cli": "^17.0.7"
},
"files": [
"lib",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {describe, it} from 'node:test';

import expect from 'expect';

import {
Expand All @@ -6,18 +8,18 @@ import {
setupHttpHooks,
} from './utils.js';

describe('@puppeteer/ng-schematics: config', () => {
void describe('@puppeteer/ng-schematics: config', () => {
setupHttpHooks();

describe('Single Project', () => {
it('should create default file', async () => {
void describe('Single Project', () => {
void it('should create default file', async () => {
const tree = await buildTestingTree('config', 'single');
expect(tree.files).toContain('/.puppeteerrc.mjs');
});
});

describe('Multi projects', () => {
it('should create default file', async () => {
void describe('Multi projects', () => {
void it('should create default file', async () => {
const tree = await buildTestingTree('config', 'multi');
expect(tree.files).toContain('/.puppeteerrc.mjs');
expect(tree.files).not.toContain(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {describe, it} from 'node:test';

import expect from 'expect';

import {
Expand All @@ -6,19 +8,19 @@ import {
setupHttpHooks,
} from './utils.js';

describe('@puppeteer/ng-schematics: e2e', () => {
void describe('@puppeteer/ng-schematics: e2e', () => {
setupHttpHooks();

describe('Single Project', () => {
it('should create default file', async () => {
void describe('Single Project', () => {
void it('should create default file', async () => {
const tree = await buildTestingTree('e2e', 'single', {
name: 'myTest',
});
expect(tree.files).toContain('/e2e/tests/my-test.e2e.ts');
expect(tree.files).not.toContain('/e2e/tests/my-test.test.ts');
});

it('should create Node file', async () => {
void it('should create Node file', async () => {
const tree = await buildTestingTree('e2e', 'single', {
name: 'myTest',
testRunner: 'node',
Expand All @@ -27,7 +29,7 @@ describe('@puppeteer/ng-schematics: e2e', () => {
expect(tree.files).toContain('/e2e/tests/my-test.test.ts');
});

it('should create file with route', async () => {
void it('should create file with route', async () => {
const route = 'home';
const tree = await buildTestingTree('e2e', 'single', {
name: 'myTest',
Expand All @@ -39,7 +41,7 @@ describe('@puppeteer/ng-schematics: e2e', () => {
);
});

it('should create with route with starting slash', async () => {
void it('should create with route with starting slash', async () => {
const route = '/home';
const tree = await buildTestingTree('e2e', 'single', {
name: 'myTest',
Expand All @@ -52,8 +54,8 @@ describe('@puppeteer/ng-schematics: e2e', () => {
});
});

describe('Multi projects', () => {
it('should create default file', async () => {
void describe('Multi projects', () => {
void it('should create default file', async () => {
const tree = await buildTestingTree('e2e', 'multi', {
name: 'myTest',
});
Expand All @@ -65,7 +67,7 @@ describe('@puppeteer/ng-schematics: e2e', () => {
);
});

it('should create Node file', async () => {
void it('should create Node file', async () => {
const tree = await buildTestingTree('e2e', 'multi', {
name: 'myTest',
testRunner: 'node',
Expand All @@ -78,7 +80,7 @@ describe('@puppeteer/ng-schematics: e2e', () => {
);
});

it('should create file with route', async () => {
void it('should create file with route', async () => {
const route = 'home';
const tree = await buildTestingTree('e2e', 'multi', {
name: 'myTest',
Expand All @@ -92,7 +94,7 @@ describe('@puppeteer/ng-schematics: e2e', () => {
).toContain(`setupBrowserHooks('${route}');`);
});

it('should create with route with starting slash', async () => {
void it('should create with route with starting slash', async () => {
const route = '/home';
const tree = await buildTestingTree('e2e', 'multi', {
name: 'myTest',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {describe, it} from 'node:test';

import expect from 'expect';

import {
Expand All @@ -11,11 +13,11 @@ import {
setupHttpHooks,
} from './utils.js';

describe('@puppeteer/ng-schematics: ng-add', () => {
void describe('@puppeteer/ng-schematics: ng-add', () => {
setupHttpHooks();

describe('Single Project', () => {
it('should create base files and update to "package.json"', async () => {
void describe('Single Project', () => {
void it('should create base files and update to "package.json"', async () => {
const tree = await buildTestingTree('ng-add');
const {devDependencies, scripts} = getPackageJson(tree);
const {builder, configurations} = getAngularJsonScripts(tree);
Expand All @@ -32,7 +34,7 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
},
});
});
it('should update create proper "ng" command for non default tester', async () => {
void it('should update create proper "ng" command for non default tester', async () => {
let tree = await buildTestingTree('ng-add', 'single');
// Re-run schematic to have e2e populated
tree = await runSchematic(tree, 'ng-add');
Expand All @@ -42,12 +44,12 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
expect(scripts['puppeteer']).toBe('ng run sandbox:puppeteer');
expect(builder).toBe('@puppeteer/ng-schematics:puppeteer');
});
it('should not create Puppeteer config', async () => {
void it('should not create Puppeteer config', async () => {
const {files} = await buildTestingTree('ng-add', 'single');

expect(files).not.toContain('/.puppeteerrc.cjs');
});
it('should create Jasmine files and update "package.json"', async () => {
void it('should create Jasmine files and update "package.json"', async () => {
const tree = await buildTestingTree('ng-add', 'single', {
testRunner: 'jasmine',
});
Expand All @@ -58,7 +60,7 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
expect(devDependencies).toContain('jasmine');
expect(options['testRunner']).toBe('jasmine');
});
it('should create Jest files and update "package.json"', async () => {
void it('should create Jest files and update "package.json"', async () => {
const tree = await buildTestingTree('ng-add', 'single', {
testRunner: 'jest',
});
Expand All @@ -70,7 +72,7 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
expect(devDependencies).toContain('@types/jest');
expect(options['testRunner']).toBe('jest');
});
it('should create Mocha files and update "package.json"', async () => {
void it('should create Mocha files and update "package.json"', async () => {
const tree = await buildTestingTree('ng-add', 'single', {
testRunner: 'mocha',
});
Expand All @@ -82,7 +84,7 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
expect(devDependencies).toContain('@types/mocha');
expect(options['testRunner']).toBe('mocha');
});
it('should create Node files', async () => {
void it('should create Node files', async () => {
const tree = await buildTestingTree('ng-add', 'single', {
testRunner: 'node',
});
Expand All @@ -93,7 +95,7 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
expect(tree.files).toContain('/e2e/tests/app.test.ts');
expect(options['testRunner']).toBe('node');
});
it('should create TypeScript files', async () => {
void it('should create TypeScript files', async () => {
const tree = await buildTestingTree('ng-add', 'single');
const tsConfigPath = '/e2e/tsconfig.json';
const tsConfig = tree.readJson(tsConfigPath);
Expand All @@ -106,16 +108,16 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
},
});
});
it('should not create port value', async () => {
void it('should not create port value', async () => {
const tree = await buildTestingTree('ng-add');

const {options} = getAngularJsonScripts(tree);
expect(options['port']).toBeUndefined();
});
});

describe('Multi projects Application', () => {
it('should create base files and update to "package.json"', async () => {
void describe('Multi projects Application', () => {
void it('should create base files and update to "package.json"', async () => {
const tree = await buildTestingTree('ng-add', 'multi');
const {devDependencies, scripts} = getPackageJson(tree);
const {builder, configurations} = getAngularJsonScripts(tree);
Expand All @@ -138,7 +140,7 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
},
});
});
it('should update create proper "ng" command for non default tester', async () => {
void it('should update create proper "ng" command for non default tester', async () => {
let tree = await buildTestingTree('ng-add', 'multi');
// Re-run schematic to have e2e populated
tree = await runSchematic(tree, 'ng-add');
Expand All @@ -148,13 +150,13 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
expect(scripts['puppeteer']).toBe('ng run sandbox:puppeteer');
expect(builder).toBe('@puppeteer/ng-schematics:puppeteer');
});
it('should not create Puppeteer config', async () => {
void it('should not create Puppeteer config', async () => {
const {files} = await buildTestingTree('ng-add', 'multi');

expect(files).not.toContain(getMultiApplicationFile('.puppeteerrc.cjs'));
expect(files).not.toContain('/.puppeteerrc.cjs');
});
it('should create Jasmine files and update "package.json"', async () => {
void it('should create Jasmine files and update "package.json"', async () => {
const tree = await buildTestingTree('ng-add', 'multi', {
testRunner: 'jasmine',
});
Expand All @@ -165,7 +167,7 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
expect(devDependencies).toContain('jasmine');
expect(options['testRunner']).toBe('jasmine');
});
it('should create Jest files and update "package.json"', async () => {
void it('should create Jest files and update "package.json"', async () => {
const tree = await buildTestingTree('ng-add', 'multi', {
testRunner: 'jest',
});
Expand All @@ -179,7 +181,7 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
expect(devDependencies).toContain('@types/jest');
expect(options['testRunner']).toBe('jest');
});
it('should create Mocha files and update "package.json"', async () => {
void it('should create Mocha files and update "package.json"', async () => {
const tree = await buildTestingTree('ng-add', 'multi', {
testRunner: 'mocha',
});
Expand All @@ -191,7 +193,7 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
expect(devDependencies).toContain('@types/mocha');
expect(options['testRunner']).toBe('mocha');
});
it('should create Node files', async () => {
void it('should create Node files', async () => {
const tree = await buildTestingTree('ng-add', 'multi', {
testRunner: 'node',
});
Expand All @@ -206,7 +208,7 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
);
expect(options['testRunner']).toBe('node');
});
it('should create TypeScript files', async () => {
void it('should create TypeScript files', async () => {
const tree = await buildTestingTree('ng-add', 'multi');
const tsConfigPath = getMultiApplicationFile('e2e/tsconfig.json');
const tsConfig = tree.readJson(tsConfigPath);
Expand All @@ -219,16 +221,16 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
},
});
});
it('should not create port value', async () => {
void it('should not create port value', async () => {
const tree = await buildTestingTree('ng-add');

const {options} = getAngularJsonScripts(tree);
expect(options['port']).toBeUndefined();
});
});

describe('Multi projects Library', () => {
it('should create base files and update to "package.json"', async () => {
void describe('Multi projects Library', () => {
void it('should create base files and update to "package.json"', async () => {
const tree = await buildTestingTree('ng-add', 'multi');
const config = getAngularJsonScripts(
tree,
Expand All @@ -248,7 +250,7 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
expect(config).toBeUndefined();
});

it('should not create Puppeteer config', async () => {
void it('should not create Puppeteer config', async () => {
const {files} = await buildTestingTree('ng-add', 'multi');

expect(files).not.toContain(getMultiLibraryFile('.puppeteerrc.cjs'));
Expand Down
Loading

0 comments on commit 16becdb

Please sign in to comment.