mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore(firefox): mark all Puppeteer tests that are failing on FF (#3924)
This patch: - introduces new testRunner methods `addTestDSL` and `addSuiteDSL` to add annotated test / suite. - introduces new test/suite declaration methods: `it_fails_ffox` and `describe_fails_ffox`. These are equal to `it`/`describe` for chromium tests and to `xit`/`xdescribe` for firefox. - marks all unsupported tests with `it_fails_ffox` - adds a new command-line flag `'--firefox-status'` to `//test/test.js`. This flag dumps current amount of tests that are intentionally skipped for Firefox. End goal: get rid of all `it_fails_ffox` and `describe_fails_ffox` tests. Drive-By: remove cookie tests "afterEach" hook that was removing cookies - it's not needed any more since every test is run in a designated browser context. References #3889
This commit is contained in:
@@ -97,13 +97,14 @@ const TestResult = {
|
||||
};
|
||||
|
||||
class Test {
|
||||
constructor(suite, name, callback, declaredMode, timeout) {
|
||||
constructor(suite, name, callback, declaredMode, timeout, comment) {
|
||||
this.suite = suite;
|
||||
this.name = name;
|
||||
this.fullName = (suite.fullName + ' ' + name).trim();
|
||||
this.declaredMode = declaredMode;
|
||||
this._userCallback = new UserCallback(callback, timeout);
|
||||
this.location = this._userCallback.location;
|
||||
this.comment = comment;
|
||||
|
||||
// Test results
|
||||
this.result = null;
|
||||
@@ -114,11 +115,12 @@ class Test {
|
||||
}
|
||||
|
||||
class Suite {
|
||||
constructor(parentSuite, name, declaredMode) {
|
||||
constructor(parentSuite, name, declaredMode, comment) {
|
||||
this.parentSuite = parentSuite;
|
||||
this.name = name;
|
||||
this.fullName = (parentSuite ? parentSuite.fullName + ' ' + name : name).trim();
|
||||
this.declaredMode = declaredMode;
|
||||
this.comment = comment;
|
||||
/** @type {!Array<(!Test|!Suite)>} */
|
||||
this.children = [];
|
||||
|
||||
@@ -283,32 +285,40 @@ class TestRunner extends EventEmitter {
|
||||
}
|
||||
|
||||
// bind methods so that they can be used as a DSL.
|
||||
this.describe = this._addSuite.bind(this, TestMode.Run);
|
||||
this.fdescribe = this._addSuite.bind(this, TestMode.Focus);
|
||||
this.xdescribe = this._addSuite.bind(this, TestMode.Skip);
|
||||
this.it = this._addTest.bind(this, TestMode.Run);
|
||||
this.fit = this._addTest.bind(this, TestMode.Focus);
|
||||
this.xit = this._addTest.bind(this, TestMode.Skip);
|
||||
this.describe = this._addSuite.bind(this, TestMode.Run, '');
|
||||
this.fdescribe = this._addSuite.bind(this, TestMode.Focus, '');
|
||||
this.xdescribe = this._addSuite.bind(this, TestMode.Skip, '');
|
||||
this.it = this._addTest.bind(this, TestMode.Run, '');
|
||||
this.fit = this._addTest.bind(this, TestMode.Focus, '');
|
||||
this.xit = this._addTest.bind(this, TestMode.Skip, '');
|
||||
this.beforeAll = this._addHook.bind(this, 'beforeAll');
|
||||
this.beforeEach = this._addHook.bind(this, 'beforeEach');
|
||||
this.afterAll = this._addHook.bind(this, 'afterAll');
|
||||
this.afterEach = this._addHook.bind(this, 'afterEach');
|
||||
}
|
||||
|
||||
_addTest(mode, name, callback) {
|
||||
addTestDSL(dslName, mode, comment) {
|
||||
this[dslName] = this._addTest.bind(this, mode, comment);
|
||||
}
|
||||
|
||||
addSuiteDSL(dslName, mode, comment) {
|
||||
this[dslName] = this._addSuite.bind(this, mode, comment);
|
||||
}
|
||||
|
||||
_addTest(mode, comment, name, callback) {
|
||||
let suite = this._currentSuite;
|
||||
let isSkipped = suite.declaredMode === TestMode.Skip;
|
||||
while ((suite = suite.parentSuite))
|
||||
isSkipped |= suite.declaredMode === TestMode.Skip;
|
||||
const test = new Test(this._currentSuite, name, callback, isSkipped ? TestMode.Skip : mode, this._timeout);
|
||||
const test = new Test(this._currentSuite, name, callback, isSkipped ? TestMode.Skip : mode, this._timeout, comment);
|
||||
this._currentSuite.children.push(test);
|
||||
this._tests.push(test);
|
||||
this._hasFocusedTestsOrSuites = this._hasFocusedTestsOrSuites || mode === TestMode.Focus;
|
||||
}
|
||||
|
||||
_addSuite(mode, name, callback) {
|
||||
_addSuite(mode, comment, name, callback) {
|
||||
const oldSuite = this._currentSuite;
|
||||
const suite = new Suite(this._currentSuite, name, mode);
|
||||
const suite = new Suite(this._currentSuite, name, mode, comment);
|
||||
this._currentSuite.children.push(suite);
|
||||
this._currentSuite = suite;
|
||||
callback();
|
||||
|
||||
Reference in New Issue
Block a user