chore: use node test runner (#11574)

This commit is contained in:
Nikolay Vitkov 2024-01-03 10:57:25 +01:00 committed by GitHub
parent 613f7162d7
commit 16becdbc3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 66 additions and 67 deletions

View File

@ -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
@ -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 }}

10
package-lock.json generated
View File

@ -10788,9 +10788,7 @@
},
"devDependencies": {
"@angular/cli": "^17.0.7",
"@schematics/angular": "^17.0.7",
"@types/node": "^16.18.61",
"rxjs": "7.8.1"
"@schematics/angular": "^17.0.7"
},
"engines": {
"node": ">=16.13.2"
@ -10903,12 +10901,6 @@
"yarn": ">= 1.13.0"
}
},
"packages/ng-schematics/node_modules/@types/node": {
"version": "16.18.68",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.68.tgz",
"integrity": "sha512-sG3hPIQwJLoewrN7cr0dwEy+yF5nD4D/4FxtQpFciRD/xwUzgD+G05uxZHv5mhfXo4F9Jkp13jjn0CC2q325sg==",
"dev": true
},
"packages/ng-schematics/node_modules/ajv": {
"version": "8.12.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",

View File

@ -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';

View File

@ -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/**"
],
@ -25,8 +25,8 @@
"*.tsbuildinfo"
]
},
"test": {
"command": "mocha",
"unit": {
"command": "node --test --test-reporter spec test/build",
"dependencies": [
"build"
]
@ -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",

View File

@ -1,3 +1,5 @@
import {describe, it} from 'node:test';
import expect from 'expect';
import {
@ -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(

View File

@ -1,3 +1,5 @@
import {describe, it} from 'node:test';
import expect from 'expect';
import {
@ -6,11 +8,11 @@ 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',
});
@ -18,7 +20,7 @@ describe('@puppeteer/ng-schematics: e2e', () => {
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',
@ -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',
@ -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',
@ -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',
});
@ -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',
@ -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',
@ -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',

View File

@ -1,3 +1,5 @@
import {describe, it} from 'node:test';
import expect from 'expect';
import {
@ -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);
@ -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');
@ -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',
});
@ -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',
});
@ -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',
});
@ -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',
});
@ -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);
@ -106,7 +108,7 @@ 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);
@ -114,8 +116,8 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
});
});
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);
@ -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');
@ -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',
});
@ -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',
});
@ -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',
});
@ -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',
});
@ -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);
@ -219,7 +221,7 @@ 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);
@ -227,8 +229,8 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
});
});
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,
@ -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'));

View File

@ -1,4 +1,5 @@
import https from 'https';
import {before, after} from 'node:test';
import {join} from 'path';
import type {JsonObject} from '@angular-devkit/core';

View File

@ -14,9 +14,11 @@
* limitations under the License.
*/
const fs = require('fs/promises');
const {join} = require('path');
const path = require('path');
import fs from 'fs/promises';
import path from 'path';
import url from 'url';
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
/**
*
@ -44,8 +46,8 @@ async function findSchemaFiles(directory, files = []) {
}
async function copySchemaFiles() {
const srcDir = join(__dirname, '..', 'src');
const outputDir = join(__dirname, '..', 'lib');
const srcDir = path.join(__dirname, '..', 'src');
const outputDir = path.join(__dirname, '..', 'lib');
const files = await findSchemaFiles(srcDir);
const moves = files.map(file => {

View File

@ -14,5 +14,5 @@
},
"include": ["src/**/*"],
"exclude": ["src/**/files/**/*"],
"references": [{"path": "./tsconfig.spec.json"}]
"references": [{"path": "./tsconfig.test.json"}]
}

View File

@ -3,7 +3,7 @@
"compilerOptions": {
"rootDir": "test/src/",
"outDir": "test/build/",
"types": ["node", "mocha"]
"types": ["node"]
},
"include": ["test/src/**/*"],
"exclude": ["test/build/**/*"]