diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0853807cd2..dde26bee9fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} diff --git a/package-lock.json b/package-lock.json index 334f6ce5761..970fa1fe9c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/packages/browsers/test/src/versions.ts b/packages/browsers/test/src/versions.ts index d9bc3ad72b1..7955bc5726f 100644 --- a/packages/browsers/test/src/versions.ts +++ b/packages/browsers/test/src/versions.ts @@ -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'; diff --git a/packages/ng-schematics/package.json b/packages/ng-schematics/package.json index afa1882105d..b3e4f945b10 100644 --- a/packages/ng-schematics/package.json +++ b/packages/ng-schematics/package.json @@ -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", diff --git a/packages/ng-schematics/test/src/config.spec.ts b/packages/ng-schematics/test/src/config.test.ts similarity index 63% rename from packages/ng-schematics/test/src/config.spec.ts rename to packages/ng-schematics/test/src/config.test.ts index facdf2cf5c0..e4ec03ed547 100644 --- a/packages/ng-schematics/test/src/config.spec.ts +++ b/packages/ng-schematics/test/src/config.test.ts @@ -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( diff --git a/packages/ng-schematics/test/src/e2e.spec.ts b/packages/ng-schematics/test/src/e2e.test.ts similarity index 80% rename from packages/ng-schematics/test/src/e2e.spec.ts rename to packages/ng-schematics/test/src/e2e.test.ts index 356bbc3d871..8ae211cd59d 100644 --- a/packages/ng-schematics/test/src/e2e.spec.ts +++ b/packages/ng-schematics/test/src/e2e.test.ts @@ -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', diff --git a/packages/ng-schematics/test/src/ng-add.spec.ts b/packages/ng-schematics/test/src/ng-add.test.ts similarity index 82% rename from packages/ng-schematics/test/src/ng-add.spec.ts rename to packages/ng-schematics/test/src/ng-add.test.ts index 93cd07e7060..d912c5dc3d2 100644 --- a/packages/ng-schematics/test/src/ng-add.spec.ts +++ b/packages/ng-schematics/test/src/ng-add.test.ts @@ -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')); diff --git a/packages/ng-schematics/test/src/utils.ts b/packages/ng-schematics/test/src/utils.ts index 18d928b7a5f..98bf7df2941 100644 --- a/packages/ng-schematics/test/src/utils.ts +++ b/packages/ng-schematics/test/src/utils.ts @@ -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'; diff --git a/packages/ng-schematics/tools/copySchemaFiles.js b/packages/ng-schematics/tools/copySchemaFiles.mjs similarity index 87% rename from packages/ng-schematics/tools/copySchemaFiles.js rename to packages/ng-schematics/tools/copySchemaFiles.mjs index bca61b81019..f64ec05cf2b 100644 --- a/packages/ng-schematics/tools/copySchemaFiles.js +++ b/packages/ng-schematics/tools/copySchemaFiles.mjs @@ -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 => { diff --git a/packages/ng-schematics/tsconfig.json b/packages/ng-schematics/tsconfig.json index c2b2a9386f6..aed9de12bce 100644 --- a/packages/ng-schematics/tsconfig.json +++ b/packages/ng-schematics/tsconfig.json @@ -14,5 +14,5 @@ }, "include": ["src/**/*"], "exclude": ["src/**/files/**/*"], - "references": [{"path": "./tsconfig.spec.json"}] + "references": [{"path": "./tsconfig.test.json"}] } diff --git a/packages/ng-schematics/tsconfig.spec.json b/packages/ng-schematics/tsconfig.test.json similarity index 85% rename from packages/ng-schematics/tsconfig.spec.json rename to packages/ng-schematics/tsconfig.test.json index 8afa532cb13..3d1d65e449e 100644 --- a/packages/ng-schematics/tsconfig.spec.json +++ b/packages/ng-schematics/tsconfig.test.json @@ -3,7 +3,7 @@ "compilerOptions": { "rootDir": "test/src/", "outDir": "test/build/", - "types": ["node", "mocha"] + "types": ["node"] }, "include": ["test/src/**/*"], "exclude": ["test/build/**/*"]