mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
test: wire test commands to jest (#3014)
This commit is contained in:
parent
8904f401c2
commit
9d9801192e
42
.github/workflows/tests.yml
vendored
42
.github/workflows/tests.yml
vendored
@ -37,14 +37,12 @@ jobs:
|
||||
# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR
|
||||
# Wrap `npm run` in a subshell to redirect STDERR to file.
|
||||
# Enable core dumps in the subshell.
|
||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run test 2>./testrun.log"
|
||||
env:
|
||||
BROWSER: ${{ matrix.browser }}
|
||||
DEBUG: "*,-pw:wrapped*"
|
||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run jest -- --testTimeout=30000"
|
||||
if: ${{ always() }}
|
||||
env:
|
||||
BROWSER: ${{ matrix.browser }}
|
||||
DEBUG: "*,-pw:wrapped*"
|
||||
DEBUG_FILE: "testrun.log"
|
||||
- uses: actions/upload-artifact@v1
|
||||
if: failure()
|
||||
with:
|
||||
@ -76,14 +74,11 @@ jobs:
|
||||
- uses: microsoft/playwright-github-action@v1
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
- run: npm run test 2>./${{ matrix.browser }}-mac-testrun.log
|
||||
- run: npm run jest -- --testTimeout=30000
|
||||
env:
|
||||
BROWSER: ${{ matrix.browser }}
|
||||
DEBUG: "*,-pw:wrapped*"
|
||||
- run: npm run jest -- --testTimeout=30000
|
||||
if: ${{ always() }}
|
||||
env:
|
||||
BROWSER: ${{ matrix.browser }}
|
||||
DEBUG_FILE: "testrun.log"
|
||||
- uses: actions/upload-artifact@v1
|
||||
if: failure()
|
||||
with:
|
||||
@ -93,7 +88,7 @@ jobs:
|
||||
if: failure()
|
||||
with:
|
||||
name: ${{ matrix.browser }}-mac-testrun.log
|
||||
path: ${{ matrix.browser }}-mac-testrun.log
|
||||
path: testrun.log
|
||||
|
||||
test_win:
|
||||
name: "Windows"
|
||||
@ -110,16 +105,12 @@ jobs:
|
||||
- uses: microsoft/playwright-github-action@v1
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
- run: npm run test 2>./${{ matrix.browser }}-win-testrun.log
|
||||
- run: npm run jest -- --testTimeout=30000
|
||||
shell: bash
|
||||
env:
|
||||
BROWSER: ${{ matrix.browser }}
|
||||
DEBUG: "*,-pw:wrapped*"
|
||||
- run: npm run jest -- --testTimeout=30000
|
||||
if: ${{ always() }}
|
||||
shell: bash
|
||||
env:
|
||||
BROWSER: ${{ matrix.browser }}
|
||||
DEBUG_FILE: "testrun.log"
|
||||
- uses: actions/upload-artifact@v1
|
||||
if: failure()
|
||||
with:
|
||||
@ -129,7 +120,7 @@ jobs:
|
||||
if: failure()
|
||||
with:
|
||||
name: ${{ matrix.browser }}-win-testrun.log
|
||||
path: ${{ matrix.browser }}-win-testrun.log
|
||||
path: testrun.log
|
||||
|
||||
test-package-installations:
|
||||
runs-on: ubuntu-latest
|
||||
@ -166,30 +157,29 @@ jobs:
|
||||
# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR
|
||||
# Wrap `npm run` in a subshell to redirect STDERR to file.
|
||||
# Enable core dumps in the subshell.
|
||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run test -- --line-break=100 2>./headful-linux-testrun.log"
|
||||
env:
|
||||
DEBUG: "*"
|
||||
HEADLESS: "false"
|
||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run jest -- --testTimeout=30000"
|
||||
if: ${{ always() }}
|
||||
env:
|
||||
BROWSER: "chromium"
|
||||
HEADLESS: "false"
|
||||
DEBUG_FILE: "testrun.log"
|
||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run jest -- --testTimeout=30000"
|
||||
if: ${{ always() }}
|
||||
env:
|
||||
BROWSER: "firefox"
|
||||
HEADLESS: "false"
|
||||
DEBUG_FILE: "testrun.log"
|
||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run jest -- --testTimeout=30000"
|
||||
if: ${{ always() }}
|
||||
env:
|
||||
BROWSER: "webkit"
|
||||
HEADLESS: "false"
|
||||
DEBUG_FILE: "testrun.log"
|
||||
- uses: actions/upload-artifact@v1
|
||||
if: failure()
|
||||
with:
|
||||
name: headful-linux-testrun.log
|
||||
path: headful-linux-testrun.log
|
||||
path: testrun.log
|
||||
- uses: actions/upload-artifact@v1
|
||||
if: failure()
|
||||
with:
|
||||
@ -218,15 +208,11 @@ jobs:
|
||||
# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR
|
||||
# Wrap `npm run` in a subshell to redirect STDERR to file.
|
||||
# Enable core dumps in the subshell.
|
||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run test 2>./testrun.log"
|
||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run jest -- --testTimeout=30000"
|
||||
env:
|
||||
BROWSER: ${{ matrix.browser }}
|
||||
DEBUG: "*,-pw:wrapped*"
|
||||
PWCHANNEL: ${{ matrix.transport }}
|
||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run jest -- --testTimeout=30000"
|
||||
if: ${{ always() }}
|
||||
env:
|
||||
BROWSER: ${{ matrix.browser }}
|
||||
DEBUG_FILE: "testrun.log"
|
||||
PWCHANNEL: ${{ matrix.transport }}
|
||||
- uses: actions/upload-artifact@v1
|
||||
if: failure()
|
||||
|
||||
12
package.json
12
package.json
@ -9,14 +9,10 @@
|
||||
"node": ">=10.15.0"
|
||||
},
|
||||
"scripts": {
|
||||
"ctest": "cross-env BROWSER=chromium node --unhandled-rejections=strict test/test.js",
|
||||
"ftest": "cross-env BROWSER=firefox node --unhandled-rejections=strict test/test.js",
|
||||
"wtest": "cross-env BROWSER=webkit node --unhandled-rejections=strict test/test.js",
|
||||
"test": "cross-env node --unhandled-rejections=strict test/test.js",
|
||||
"ccoverage": "cross-env COVERAGE=true BROWSER=chromium node --unhandled-rejections=strict test/test.js",
|
||||
"fcoverage": "cross-env COVERAGE=true BROWSER=firefox node --unhandled-rejections=strict test/test.js",
|
||||
"wcoverage": "cross-env COVERAGE=true BROWSER=webkit node --unhandled-rejections=strict test/test.js",
|
||||
"coverage": "cross-env COVERAGE=true node --unhandled-rejections=strict test/test.js",
|
||||
"ctest": "cross-env BROWSER=chromium npm run jest",
|
||||
"ftest": "cross-env BROWSER=firefox npm run jest",
|
||||
"wtest": "cross-env BROWSER=webkit npm run jest",
|
||||
"test": "npm run ctest && npm run ftest && npm run wtest",
|
||||
"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",
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import * as debug from 'debug';
|
||||
import * as fs from 'fs';
|
||||
import { helper } from './helper';
|
||||
import { LoggerSink, LoggerSeverity } from './loggerSink';
|
||||
|
||||
@ -142,6 +143,19 @@ const colorMap = new Map<string, number>([
|
||||
|
||||
export class DebugLoggerSink {
|
||||
private _debuggers = new Map<string, debug.IDebugger>();
|
||||
constructor() {
|
||||
if (process.env.DEBUG_FILE) {
|
||||
const ansiRegex = new RegExp([
|
||||
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
||||
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
|
||||
].join('|'), 'g');
|
||||
const stream = fs.createWriteStream(process.env.DEBUG_FILE);
|
||||
(debug as any).log = (data: string) => {
|
||||
stream.write(data.replace(ansiRegex, ''));
|
||||
stream.write('\n');
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
isEnabled(name: string, severity: LoggerSeverity): boolean {
|
||||
return debug.enabled(`pw:${name}`);
|
||||
|
||||
@ -15,11 +15,10 @@
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
const config = require('../test.config');
|
||||
const utils = require('../utils');
|
||||
|
||||
const electronName = process.platform === 'win32' ? 'electron.cmd' : 'electron';
|
||||
|
||||
const { CHROMIUM } = testOptions;
|
||||
|
||||
registerFixture('application', async ({playwright}, test) => {
|
||||
const electronPath = path.join(__dirname, '..', '..', 'node_modules', '.bin', electronName);
|
||||
const application = await playwright.electron.launch(electronPath, {
|
||||
@ -41,7 +40,7 @@ registerFixture('window', async ({application}, test) => {
|
||||
}
|
||||
});
|
||||
|
||||
describe('Electron', function() {
|
||||
describe.skip(!CHROMIUM)('Electron', function() {
|
||||
it('should script application', async ({ application }) => {
|
||||
const appPath = await application.evaluate(async ({ app }) => app.getAppPath());
|
||||
expect(appPath).toContain('electron');
|
||||
@ -124,7 +123,7 @@ describe('Electron', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Electron per window', function() {
|
||||
describe.skip(!CHROMIUM)('Electron per window', function() {
|
||||
it('should click the button', async({window, server}) => {
|
||||
await window.goto(server.PREFIX + '/input/button.html');
|
||||
await window.click('button');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user