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

Rewrite: Fix webdriver for IE and Firefox #244

Merged
merged 4 commits into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cli/test/fixture/client-leak.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*eslint-env mocha*/
'use strict';

describe('test', () => {
it('does not leak client functions into global scope', () => {
if (typeof MochifyReporter !== 'undefined') {
throw new Error('MochifyReporter leaked');
}
});
});
43 changes: 24 additions & 19 deletions cli/test/jsdom.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ const { assert } = require('@sinonjs/referee-sinon');
const execa = require('execa');

describe('jsdom', () => {
it('passes', async () => {
const result = await execa(
'../../index.js',
['--driver', 'jsdom', 'passes.js'],
{
async function run(file) {
try {
return await execa('../../index.js', ['--driver', 'jsdom', file], {
cwd: path.join(__dirname, 'fixture')
}
);
});
} catch (error) {
return error;
}
}

it('passes', async () => {
const result = await run('passes.js');

assert.isFalse(result.failed);
const json = JSON.parse(result.stdout);
Expand All @@ -21,22 +25,23 @@ describe('jsdom', () => {
});

it('fails', async () => {
let result;
try {
result = await execa(
'../../index.js',
['--driver', 'jsdom', 'fails.js'],
{
cwd: path.join(__dirname, 'fixture')
}
);
} catch (error) {
result = error;
}
const result = await run('fails.js');

assert.isTrue(result.failed);
const json = JSON.parse(result.stdout);
assert.equals(json.tests.length, 1);
assert.equals(json.tests[0].fullTitle, 'test fails');
});

it('does not leak client functions into global scope', async () => {
const result = await run('client-leak.js');

assert.isFalse(result.failed);
const json = JSON.parse(result.stdout);
assert.equals(json.tests.length, 1);
assert.equals(
json.tests[0].fullTitle,
'test does not leak client functions into global scope'
);
});
});
59 changes: 28 additions & 31 deletions cli/test/playwright.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ const { assert } = require('@sinonjs/referee-sinon');
const execa = require('execa');

describe('playwright', () => {
async function run(file) {
try {
return await execa(
'../../index.js',
['--driver', 'playwright', '--driver-option.engine', 'chromium', file],
{
cwd: path.join(__dirname, 'fixture')
}
);
} catch (error) {
return error;
}
}

it('passes', async () => {
const result = await execa(
'../../index.js',
[
'--driver',
'playwright',
'--driver-option.engine',
'chromium',
'passes.js'
],
{
cwd: path.join(__dirname, 'fixture')
}
);
const result = await run('passes.js');

assert.isFalse(result.failed);
const json = JSON.parse(result.stdout);
Expand All @@ -27,28 +29,23 @@ describe('playwright', () => {
});

it('fails', async () => {
let result;
try {
result = await execa(
'../../index.js',
[
'--driver',
'playwright',
'--driver-option.engine',
'chromium',
'fails.js'
],
{
cwd: path.join(__dirname, 'fixture')
}
);
} catch (error) {
result = error;
}
const result = await run('fails.js');

assert.isTrue(result.failed);
const json = JSON.parse(result.stdout);
assert.equals(json.tests.length, 1);
assert.equals(json.tests[0].fullTitle, 'test fails');
});

it('does not leak client functions into global scope', async () => {
const result = await run('client-leak.js');

assert.isFalse(result.failed);
const json = JSON.parse(result.stdout);
assert.equals(json.tests.length, 1);
assert.equals(
json.tests[0].fullTitle,
'test does not leak client functions into global scope'
);
});
});
43 changes: 24 additions & 19 deletions cli/test/puppeteer.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ const { assert } = require('@sinonjs/referee-sinon');
const execa = require('execa');

describe('puppeteer', () => {
it('passes', async () => {
const result = await execa(
'../../index.js',
['--driver', 'puppeteer', 'passes.js'],
{
async function run(file) {
try {
return await execa('../../index.js', ['--driver', 'puppeteer', file], {
cwd: path.join(__dirname, 'fixture')
}
);
});
} catch (error) {
return error;
}
}

it('passes', async () => {
const result = await run('passes.js');

assert.isFalse(result.failed);
const json = JSON.parse(result.stdout);
Expand All @@ -21,22 +25,23 @@ describe('puppeteer', () => {
});

it('fails', async () => {
let result;
try {
result = await execa(
'../../index.js',
['--driver', 'puppeteer', 'fails.js'],
{
cwd: path.join(__dirname, 'fixture')
}
);
} catch (error) {
result = error;
}
const result = await run('fails.js');

assert.isTrue(result.failed);
const json = JSON.parse(result.stdout);
assert.equals(json.tests.length, 1);
assert.equals(json.tests[0].fullTitle, 'test fails');
});

it('does not leak client functions into global scope', async () => {
const result = await run('client-leak.js');

assert.isFalse(result.failed);
const json = JSON.parse(result.stdout);
assert.equals(json.tests.length, 1);
assert.equals(
json.tests[0].fullTitle,
'test does not leak client functions into global scope'
);
});
});
Loading