Created
June 2, 2020 04:50
-
-
Save Meir017/e37474d82c17a49b545c90c89e5b1b4d to your computer and use it in GitHub Desktop.
generate-tests-list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const utils = require('./test/utils'); | |
const tests = require('./test/playwright.spec'); | |
const collected = []; | |
let current = {}; | |
var options = { | |
playwrightPath: utils.projectRoot(), | |
product: 'Firefox', | |
playwright: require('.'), | |
expect: () => { }, | |
testRunner: { | |
describe: (name, func) => { | |
if (current.name) { | |
collected.push(current); | |
current = {}; | |
} | |
current.name = name; | |
current.it = []; | |
func(options); | |
}, | |
xdescribe: (name, func) => options.testRunner.describe(name, func), | |
fdescribe: (name, func) => options.testRunner.describe(name, func), | |
beforeEach: func => { }, | |
beforeAll: func => { }, | |
afterEach: func => { }, | |
afterAll: func => { }, | |
it: (name, func) => { | |
current.it.push({ | |
name, | |
// code: func.toString() | |
}); | |
}, | |
xit: (name, func) => { | |
current.it.push({ | |
name, | |
// code: func.toString(), | |
skip: true | |
}); | |
}, | |
loadTests: (module, ...args) => { | |
if (typeof module.describe === 'function') | |
options.testRunner.describe('', module.describe); | |
if (typeof module.fdescribe === 'function') | |
options.testRunner.fdescribe('', module.fdescribe); | |
if (typeof module.xdescribe === 'function') | |
options.testRunner.xdescribe('', module.xdescribe); | |
} | |
} | |
}; | |
options.testRunner.it.skip = (skip) => (name, func) => options.testRunner.xit(name, func); | |
options.testRunner.describe.skip = (skip) => (name, func) => options.testRunner.describe(name, func); | |
tests.describe(options); | |
const fs = require('fs'); | |
fs.writeFileSync('./test.json', JSON.stringify(collected, null, 2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and the generated file - https://gist.github.com/Meir017/2a3a191683f0d3fe84aace9b486b3a94