-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from annaet/skip_ignoring_tags
Fix .skip and .only functionality
- Loading branch information
Showing
13 changed files
with
457 additions
and
285 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// sample start | ||
describe('Describe block', () => { | ||
it.only('Run this test without tag', () => { }); | ||
it.only('smoke', 'Run this test with tag', () => { }); | ||
|
||
it('Skip this test without tag', () => { }); | ||
it('smoke', 'Skip this test without tag', () => { }); | ||
}); | ||
|
||
describe.only('smoke', 'Only run this describe', () => { | ||
it.only('Run this test without tag', () => { }); | ||
it.only('wip', 'Run this test with tag', () => { }); | ||
|
||
it('Skip this test without tag', () => { }); | ||
it('wip', 'Skip this test without tag', () => { }); | ||
}); | ||
// sample end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// sample start | ||
describe('Unskipped describe', () => { | ||
it.skip('Skipped test', () => { }); | ||
it.skip('smoke', 'Skipped test', () => { }); | ||
|
||
it('Unskipped test', () => { }); | ||
it('smoke', 'Tagged test', () => { }); | ||
}); | ||
|
||
describe.skip('smoke', 'Skipped describe', () => { | ||
it.skip('Skipped test', () => { }); | ||
it.skip('wip', 'Skipped test', () => { }); | ||
|
||
it('Unskipped test', () => { }); | ||
it('wip', 'Tagged test', () => { }); | ||
}); | ||
// sample end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import browserify from 'browserify'; | ||
import through from 'through'; | ||
|
||
// @ts-ignore | ||
const transform = require('../../dist').transform; | ||
|
||
const generateConfig = () => { | ||
return { | ||
env: { | ||
CYPRESS_INCLUDE_TAGS: undefined, | ||
CYPRESS_EXCLUDE_TAGS: undefined, | ||
}, | ||
} as unknown as Cypress.PluginConfigOptions; | ||
}; | ||
|
||
const resetConfig = (config: Cypress.PluginConfigOptions) => { | ||
delete config.env.CYPRESS_INCLUDE_TAGS; | ||
delete config.env.CYPRESS_EXCLUDE_TAGS; | ||
}; | ||
|
||
const tagify = (config: Cypress.PluginConfigOptions, fileName: string, output: string[] = []): Promise<string[]> => { | ||
return new Promise((resolve, reject) => { | ||
const options = { | ||
typescript: require.resolve('typescript'), | ||
extensions: ['.js', '.ts'], | ||
plugin: [ | ||
['tsify'] | ||
], | ||
}; | ||
|
||
try { | ||
browserify(options) | ||
.transform((fileName: string) => transform(fileName, config)) | ||
.add(`${__dirname}/../../cypress/integration/${fileName}.spec.ts`) | ||
.bundle() | ||
.pipe(through(ondata, onend)); | ||
|
||
let data = '' | ||
function ondata(d: string) { data += d } | ||
function onend() { | ||
const lines = data.split('\n') | ||
const startline = lines.indexOf('// sample start') + 1; | ||
const endline = lines.length - 3; | ||
|
||
output = lines.slice(startline, endline); | ||
resolve(output); | ||
} | ||
} catch (err) { | ||
reject(err); | ||
} | ||
}); | ||
}; | ||
|
||
export { | ||
generateConfig, | ||
resetConfig, | ||
tagify, | ||
}; |
Oops, something went wrong.