Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: actions #1

Merged
merged 18 commits into from
Mar 8, 2020
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{*.yml}]
[*.yml]
indent_style = space
indent_size = 2

Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: tests
env:
CI: true
FORCE_COLOR: 1
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
chromium_linux:
name: "Chromium Linux"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Install required packages
run: |
sudo apt-get update
sudo apt-get install libgbm-dev
sudo apt-get install xvfb
- run: yarn
- run: ./cli.js mocks/test.mocha.js
- run: ./cli.js mocks/test.mocha.js --incognito
- run: ./cli.js mocks/test.mocha.js --mode worker
- run: xvfb-run -a ./cli.js mocks/test.mocha.js --extension
- run: ./cli.js mocks/test.tape.js --runner tape
- run: ./cli.js mocks/benchmark.js --runner benchmark

chromium_macos:
name: "Chromium Mac"
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- run: yarn
- run: ./cli.js mocks/test.mocha.js

chromium_win:
name: "Chromium Win"
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- run: yarn
- run: ./cli.js mocks/test.mocha.js
shell: bash

webkit_linux:
name: "WebKit Linux"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Install required packages
run: |
sudo apt-get update
sudo apt-get install libwoff1 libopus0 libwebp6 libwebpdemux2 libenchant1c2a libgudev-1.0-0 libsecret-1-0 libhyphen0 libgdk-pixbuf2.0-0 libegl1 libgles2 libevent-2.1-6 libnotify4 libxslt1.1
sudo apt-get install xvfb
- run: yarn
- run: ./cli.js mocks/test.mocha.js --browser webkit

firefox_linux:
name: "Firefox Linux"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Install required packages
run: |
sudo apt-get update
sudo apt-get install xvfb
- run: yarn
- run: ./cli.js mocks/test.mocha.js --browser firefox
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

3 changes: 1 addition & 2 deletions mocks/test.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ describe('Array', () => {

it('should fail ', () => {
// console.log(chrome);
// localStorage.setItem('myCat', 'Tom');
assert.equal([1, 2, 3].indexOf(2), -1);
assert.equal([1, 2, 3].indexOf(2), 1);
});
});
});
12 changes: 3 additions & 9 deletions mocks/test.tape.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,13 @@ const debug = require('debug');
const error = debug('app:error');

test('timing test', (t) => {
t.plan(2);

t.equal(typeof Date.now, 'function');
const start = Date.now();

setTimeout(() => {
t.equal(Date.now() - start, 100);
}, 100);
t.end();
});

test('controller exists', (t) => {
t.plan(1);
error('testing debug');
t.ok(self.pwTestController);
t.equal(typeof Date.now, 'function');
t.end();
});

7 changes: 1 addition & 6 deletions mocks/test2.tape.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
const test = require('tape');

test('timing test 2', (t) => {
t.plan(2);
t.plan(1);

t.equal(typeof Date.now, 'function');
const start = Date.now();

setTimeout(() => {
t.equal(Date.now() - start, 100);
}, 100);
});
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# playwright-test [![NPM Version](https://img.shields.io/npm/v/playwright-test.svg)](https://www.npmjs.com/package/playwright-test) [![NPM Downloads](https://img.shields.io/npm/dt/playwright-test.svg)](https://www.npmjs.com/package/playwright-test) [![NPM License](https://img.shields.io/npm/l/playwright-test.svg)](https://www.npmjs.com/package/playwright-test) [![Build Status](https://travis-ci.org/hugomrdias/playwright-test.svg?branch=master)](https://travis-ci.org/hugomrdias/playwright-test)
# playwright-test [![NPM Version](https://img.shields.io/npm/v/playwright-test.svg)](https://www.npmjs.com/package/playwright-test) [![NPM Downloads](https://img.shields.io/npm/dt/playwright-test.svg)](https://www.npmjs.com/package/playwright-test) [![NPM License](https://img.shields.io/npm/l/playwright-test.svg)](https://www.npmjs.com/package/playwright-test) ![tests](https://github.com/hugomrdias/playwright-test/workflows/tests/badge.svg)

> Run mocha, tape and benchmark.js scripts inside real browsers with `playwright`.

Expand Down
5 changes: 3 additions & 2 deletions src/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ class Runner {
args: this.options.extension ? [
`--disable-extensions-except=${this.dir}`,
`--load-extension=${this.dir}`
] : []
] : [],
dumpio: process.env.PW_TEST_DUMPIO || false
};

// extension only works in incognito for now
Expand All @@ -99,7 +100,7 @@ class Runner {

async setupPage() {
if (this.options.extension) {
const targets = await this.context.targets();
const targets = await this.browser.targets();
const backgroundPageTarget = targets.find(target => target.type() === 'background_page');

this.page = await backgroundPageTarget.page();
Expand Down
4 changes: 4 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ const getPw = async (browserName, cachePath, spinner) => {
}
}

if (process.env.CI) {
cachePath = path.join(process.cwd(), '.cache');
}

if (!fs.existsSync(cachePath)) {
await fs.promises.mkdir(cachePath);
}
Expand Down