diff --git a/package-lock.json b/package-lock.json index f0bfdc2e377..e4cde3f507f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,8 @@ "test", "test/installation", "tools/eslint", - "tools/doctest" + "tools/doctest", + "tools/mocha-runner" ], "devDependencies": { "@actions/core": "1.10.1", @@ -1188,6 +1189,10 @@ "resolved": "tools/eslint", "link": true }, + "node_modules/@puppeteer/mocha-runner": { + "resolved": "tools/mocha-runner", + "link": true + }, "node_modules/@puppeteer/ng-schematics": { "resolved": "packages/ng-schematics", "link": true @@ -11008,6 +11013,13 @@ "name": "@puppeteer/eslint", "version": "0.1.0", "license": "Apache-2.0" + }, + "tools/mocha-runner": { + "version": "0.1.0", + "license": "Apache-2.0", + "bin": { + "mocha-runner": "bin/mocha-runner.js" + } } } } diff --git a/package.json b/package.json index 694724e91c3..de244b02aae 100644 --- a/package.json +++ b/package.json @@ -110,9 +110,10 @@ ] }, "test": { - "command": "cross-env PUPPETEER_DEFERRED_PROMISE_DEBUG_TIMEOUT=20000 node tools/mocha-runner/lib/main.js --min-tests 1003", + "command": "cross-env PUPPETEER_DEFERRED_PROMISE_DEBUG_TIMEOUT=20000 npx ./tools/mocha-runner --min-tests 1003", "dependencies": [ - "./test:build" + "./test:build", + "./tools/mocha-runner:build" ] } }, @@ -195,6 +196,7 @@ "test", "test/installation", "tools/eslint", - "tools/doctest" + "tools/doctest", + "tools/mocha-runner" ] } diff --git a/test/package.json b/test/package.json index ee07d0f7820..74a5af0afbc 100644 --- a/test/package.json +++ b/test/package.json @@ -15,7 +15,6 @@ "../packages/testserver:build" ], "files": [ - "../tools/mocha-runner/**", "src/**" ], "output": [ diff --git a/test/tsconfig.json b/test/tsconfig.json index a5e22137244..fdcd35374d4 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -6,6 +6,5 @@ "outDir": "build", "rootDir": "src" }, - "include": ["src"], - "references": [{"path": "../tools/mocha-runner/tsconfig.json"}] + "include": ["src"] } diff --git a/tools/mocha-runner/README.md b/tools/mocha-runner/README.md index f0107f19bdf..adb5c2e610a 100644 --- a/tools/mocha-runner/README.md +++ b/tools/mocha-runner/README.md @@ -6,7 +6,7 @@ It uses `/test/TestSuites.json` and `/test/TestExpectations.json` files to run m ## Running tests for Mocha Runner itself. ```bash -npm run build && npx c8 node tools/mocha-runner/lib/test.js +npm test ``` ## Running tests using Mocha Runner diff --git a/tools/mocha-runner/package.json b/tools/mocha-runner/package.json new file mode 100644 index 00000000000..59b9ef3c7f6 --- /dev/null +++ b/tools/mocha-runner/package.json @@ -0,0 +1,33 @@ +{ + "name": "@puppeteer/mocha-runner", + "version": "0.1.0", + "type": "commonjs", + "private": true, + "bin": "./bin/mocha-runner.js", + "description": "Mocha runner for Puppeteer", + "license": "Apache-2.0", + "scripts": { + "build": "wireit", + "test": "wireit", + "clean": "../clean.js" + }, + "wireit": { + "build": { + "command": "tsc -b && chmod +x ./bin/mocha-runner.js", + "clean": "if-file-deleted", + "files": [ + "src/**" + ], + "output": [ + "bin/**", + "tsconfig.tsbuildinfo" + ] + }, + "test": { + "command": "c8 node ./bin/test.js", + "dependencies": [ + "build" + ] + } + } +} diff --git a/tools/mocha-runner/src/main.ts b/tools/mocha-runner/src/mocha-runner.ts similarity index 99% rename from tools/mocha-runner/src/main.ts rename to tools/mocha-runner/src/mocha-runner.ts index e7027209cb5..5785f9aa75d 100644 --- a/tools/mocha-runner/src/main.ts +++ b/tools/mocha-runner/src/mocha-runner.ts @@ -1,3 +1,5 @@ +#! /usr/bin/env -S node + /** * Copyright 2022 Google Inc. All rights reserved. * @@ -21,23 +23,23 @@ import os from 'os'; import path from 'path'; import { - type TestExpectation, - type MochaResults, - zTestSuiteFile, zPlatform, + zTestSuiteFile, + type MochaResults, + type Platform, + type TestExpectation, type TestSuite, type TestSuiteFile, - type Platform, } from './types.js'; import { extendProcessEnv, - filterByPlatform, - readJSON, filterByParameters, + filterByPlatform, getExpectationUpdates, printSuggestions, - type RecommendedExpectation, + readJSON, writeJSON, + type RecommendedExpectation, } from './utils.js'; function getApplicableTestSuites( diff --git a/tools/mocha-runner/tsconfig.json b/tools/mocha-runner/tsconfig.json index 6f0893ee413..220a467ac17 100644 --- a/tools/mocha-runner/tsconfig.json +++ b/tools/mocha-runner/tsconfig.json @@ -1,12 +1,13 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "allowJs": true, - "composite": true, + "rootDir": "./src", + "outDir": "./bin", "module": "NodeNext", "moduleResolution": "NodeNext", - "outDir": "lib", - "rootDir": "src" - }, - "include": ["src"] + "sourceMap": true, + "declaration": false, + "declarationMap": false, + "composite": false + } }