test: move tracing tests to one-per-browser (#3781)

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.
This commit is contained in:
Andrey Lushnikov 2019-01-15 16:39:30 -08:00 committed by GitHub
parent 91c4501cc6
commit 489be90c75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -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});
});
@ -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() {

View File

@ -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;