-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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 #126 from nfpiche/describeWithDOM-enhancement
describeWithDOM enhancement
- Loading branch information
Showing
5 changed files
with
90 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,9 @@ | |
"check": "npm run lint && npm run test:all", | ||
"build": "babel src --out-dir build", | ||
"test:watch": "mocha --compilers js:babel/register --recursive src/**/__tests__/*.js --watch", | ||
"test:all": "npm run react:13 && npm test && npm run react:14 && npm test", | ||
"test:describeWithDOMOnly": "mocha --compilers js:babel/register --recursive src/**/__tests__/describeWithDOM/describeWithDOMOnly-spec.js", | ||
"test:describeWithDOMSkip": "mocha --compilers js:babel/register --recursive src/**/__tests__/describeWithDOM/describeWithDOMSkip-spec.js", | ||
"test:all": "npm run react:13 && npm test && npm run test:describeWithDOMOnly && npm run test:describeWithDOMSkip && npm run react:14 && npm test && npm run test:describeWithDOMOnly && npm run test:describeWithDOMSkip", | ||
"react:clean": "rimraf node_modules/react node_modules/react-dom node_modules/react-addons-test-utils", | ||
"react:13": "npm run react:clean && npm i [email protected]", | ||
"react:14": "npm run react:clean && npm i [email protected] [email protected] [email protected]", | ||
|
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,19 @@ | ||
import { expect } from 'chai'; | ||
import { describeWithDOM } from '../..'; | ||
|
||
describe('describeWithDOM', () => { | ||
describe('.only()', () => { | ||
describeWithDOM.only('will skip all tests not called with only', () => { | ||
it('will run only this test', () => { | ||
expect(true).to.equal(true); | ||
}); | ||
}); | ||
|
||
describeWithDOM('will not call other tests', () => { | ||
it('will not run this test', () => { | ||
// purposefully failing test that won't be called | ||
expect(true).to.equal(false); | ||
}); | ||
}); | ||
}); | ||
}); |
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,19 @@ | ||
import { expect } from 'chai'; | ||
import { describeWithDOM } from '../..'; | ||
|
||
describe('describeWithDOM', () => { | ||
describe('.skip()', () => { | ||
describeWithDOM.skip('will skip tests called with skip', () => { | ||
it('will not run this test', () => { | ||
// purposefully failing test that won't be run | ||
expect(true).to.equal(false); | ||
}); | ||
}); | ||
|
||
describeWithDOM('will still call describeWithDOM tests without .skip', () => { | ||
it('will run this test', () => { | ||
expect(true).to.equal(true); | ||
}); | ||
}); | ||
}); | ||
}); |
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,47 @@ | ||
let jsdom; | ||
|
||
try { | ||
require('jsdom'); // could throw | ||
jsdom = require('mocha-jsdom'); | ||
} catch (e) { | ||
// jsdom is not supported... | ||
} | ||
|
||
export function describeWithDOM(a, b) { | ||
describe('(uses jsdom)', () => { | ||
if (typeof jsdom === 'function') { | ||
jsdom(); | ||
describe(a, b); | ||
} else { | ||
// if jsdom isn't available, skip every test in this describe context | ||
describe.skip(a, b); | ||
} | ||
}); | ||
} | ||
|
||
function only(a, b) { | ||
describe('(uses jsdom)', () => { | ||
if (typeof jsdom === 'function') { | ||
jsdom(); | ||
describe.only(a, b); | ||
} else { | ||
// if jsdom isn't available, skip every test in this describe context | ||
describe.skip(a, b); | ||
} | ||
}); | ||
} | ||
|
||
function skip(a, b) { | ||
describe('(uses jsdom)', () => { | ||
if (typeof jsdom === 'function') { | ||
jsdom(); | ||
describe.skip(a, b); | ||
} else { | ||
// if jsdom isn't available, skip every test in this describe context | ||
describe.skip(a, b); | ||
} | ||
}); | ||
} | ||
|
||
describeWithDOM.only = only; | ||
describeWithDOM.skip = skip; |
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