Skip to content

Commit

Permalink
test: move tracing tests to one-per-browser (#3781)
Browse files Browse the repository at this point in the history
Tracing is working on a per-browser level, not per-page. In order
to paralellize these tests effectively and properly, each should run
a designated browser.
  • Loading branch information
aslushnikov committed Jan 16, 2019
1 parent 91c4501 commit 489be90
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/test.js
Expand Up @@ -167,7 +167,6 @@ describe('Browser', function() {
require('./emulation.spec.js').addTests({testRunner, expect, headless});
require('./screenshot.spec.js').addTests({testRunner, expect});
require('./target.spec.js').addTests({testRunner, expect});
require('./tracing.spec.js').addTests({testRunner, expect});
require('./worker.spec.js').addTests({testRunner, expect});
});

Expand All @@ -179,6 +178,7 @@ describe('Browser', function() {
require('./ignorehttpserrors.spec.js').addTests({testRunner, expect, defaultBrowserOptions});
require('./puppeteer.spec.js').addTests({testRunner, expect, defaultBrowserOptions});
require('./headful.spec.js').addTests({testRunner, expect, defaultBrowserOptions});
require('./tracing.spec.js').addTests({testRunner, expect, defaultBrowserOptions});

if (process.env.COVERAGE) {
describe('COVERAGE', function() {
Expand Down
13 changes: 10 additions & 3 deletions test/tracing.spec.js
Expand Up @@ -16,17 +16,24 @@

const fs = require('fs');
const path = require('path');
const utils = require('./utils');
const puppeteer = utils.requireRoot('index');

module.exports.addTests = function({testRunner, expect}) {
module.exports.addTests = function({testRunner, expect, defaultBrowserOptions}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit} = testRunner;
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;

describe('Tracing', function() {
beforeEach(function(state) {
beforeEach(async function(state) {
state.outputFile = path.join(__dirname, 'assets', `trace-${state.parallelIndex}.json`);
state.browser = await puppeteer.launch(defaultBrowserOptions);
state.page = await state.browser.newPage();
});
afterEach(function(state) {
afterEach(async function(state) {
await state.browser.close();
state.browser = null;
state.page = null;
if (fs.existsSync(state.outputFile)) {
fs.unlinkSync(state.outputFile);
state.outputFile = null;
Expand Down

0 comments on commit 489be90

Please sign in to comment.