-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(test-runner): move into its own folder and typescript project (#…
- Loading branch information
1 parent
4c56354
commit 012f942
Showing
34 changed files
with
262 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ src/webkit/protocol.ts | |
utils/generate_types/overrides.d.ts | ||
utils/generate_types/test/test.ts | ||
test/ | ||
test-runner/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,19 +9,19 @@ | |
"node": ">=10.15.0" | ||
}, | ||
"scripts": { | ||
"ctest": "cross-env BROWSER=chromium node test/runner/cli test/", | ||
"ftest": "cross-env BROWSER=firefox node test/runner/cli test/", | ||
"wtest": "cross-env BROWSER=webkit node test/runner/cli test/", | ||
"test": "node test/runner/cli test/", | ||
"ctest": "cross-env BROWSER=chromium node test-runner/cli test/", | ||
"ftest": "cross-env BROWSER=firefox node test-runner/cli test/", | ||
"wtest": "cross-env BROWSER=webkit node test-runner/cli test/", | ||
"test": "node test-runner/cli test/", | ||
"eslint": "[ \"$CI\" = true ] && eslint --quiet -f codeframe --ext js,ts ./src || eslint --ext js,ts ./src", | ||
"tsc": "tsc -p .", | ||
"tsc-installer": "tsc -p ./src/install/tsconfig.json", | ||
"doc": "node utils/doclint/cli.js", | ||
"test-infra": "node test/runner/cli utils/doclint/check_public_api/test/test.js && node test/runner/cli utils/doclint/preprocessor/test.js", | ||
"test-infra": "node test-runner/cli utils/doclint/check_public_api/test/test.js && node test-runner/cli utils/doclint/preprocessor/test.js", | ||
"lint": "npm run eslint && npm run tsc && npm run doc && npm run check-deps && npm run generate-channels && npm run test-types && npm run test-infra", | ||
"clean": "rimraf lib && rimraf types", | ||
"prepare": "node install-from-github.js", | ||
"build": "node utils/runWebpack.js --mode='development' && tsc -p . && npm run generate-types", | ||
"build": "node utils/runWebpack.js --mode='development' && tsc -p . && npm run build-testrunner && npm run generate-types", | ||
"watch": "node utils/watch.js", | ||
"test-types": "npm run generate-types && npx -p [email protected] tsc -p utils/generate_types/test/tsconfig.json && npm run typecheck-tests", | ||
"generate-types": "node utils/generate_types/", | ||
|
@@ -30,7 +30,8 @@ | |
"roll-browser": "node utils/roll_browser.js", | ||
"coverage": "node test/checkCoverage.js", | ||
"check-deps": "node utils/check_deps.js", | ||
"build-driver": "pkg --public --targets node12-linux-x64,node12-macos-x64,node12-win-x64 --out-path=drivers packages/playwright-driver/main.js" | ||
"build-driver": "pkg --public --targets node12-linux-x64,node12-macos-x64,node12-win-x64 --out-path=drivers packages/playwright-driver/main.js", | ||
"build-testrunner": "tsc -p test-runner" | ||
}, | ||
"author": { | ||
"name": "Microsoft Corporation" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env node | ||
module.exports = require('./lib/cli') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "test-runner", | ||
"version": "0.0.7", | ||
"bin": { | ||
"test-runner": "./cli.js" | ||
}, | ||
"main": "./lib/index.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* Copyright Microsoft Corporation. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import os from 'os'; | ||
import path from 'path'; | ||
import {promisify} from 'util'; | ||
import fs from 'fs'; | ||
import rimraf from 'rimraf'; | ||
import {registerFixture} from './fixtures'; | ||
|
||
|
||
declare global { | ||
type DescribeFunction = ((name: string, inner: () => void) => void) & { | ||
fail(condition: boolean): DescribeFunction; | ||
skip(condition: boolean): DescribeFunction; | ||
slow(): DescribeFunction; | ||
repeat(n: number): DescribeFunction; | ||
}; | ||
|
||
type ItFunction<STATE> = ((name: string, inner: (state: STATE) => Promise<void>) => void) & { | ||
fail(condition: boolean): ItFunction<STATE>; | ||
skip(condition: boolean): ItFunction<STATE>; | ||
slow(): ItFunction<STATE>; | ||
repeat(n: number): ItFunction<STATE>; | ||
}; | ||
|
||
const describe: DescribeFunction; | ||
const fdescribe: DescribeFunction; | ||
const xdescribe: DescribeFunction; | ||
const it: ItFunction<TestState & WorkerState & FixtureParameters>; | ||
const fit: ItFunction<TestState & WorkerState & FixtureParameters>; | ||
const dit: ItFunction<TestState & WorkerState & FixtureParameters>; | ||
const xit: ItFunction<TestState & WorkerState & FixtureParameters>; | ||
|
||
const beforeEach: (inner: (state: TestState & WorkerState & FixtureParameters) => Promise<void>) => void; | ||
const afterEach: (inner: (state: TestState & WorkerState & FixtureParameters) => Promise<void>) => void; | ||
const beforeAll: (inner: (state: WorkerState & FixtureParameters) => Promise<void>) => void; | ||
const afterAll: (inner: (state: WorkerState & FixtureParameters) => Promise<void>) => void; | ||
} | ||
|
||
const mkdtempAsync = promisify(fs.mkdtemp); | ||
const removeFolderAsync = promisify(rimraf); | ||
|
||
declare global { | ||
interface FixtureParameters { | ||
parallelIndex: number; | ||
} | ||
interface TestState { | ||
tmpDir: string; | ||
} | ||
} | ||
|
||
export {parameters, registerFixture, registerWorkerFixture, registerParameter} from './fixtures'; | ||
|
||
registerFixture('tmpDir', async ({}, test) => { | ||
const tmpDir = await mkdtempAsync(path.join(os.tmpdir(), 'playwright-test-')); | ||
await test(tmpDir); | ||
await removeFolderAsync(tmpDir).catch(e => {}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.