-
-
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.
adds .skip and .only functionality to describeWithDOM
- Loading branch information
Nate Piche
committed
Jan 19, 2016
1 parent
46f4d36
commit 803b114
Showing
5 changed files
with
72 additions
and
22 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
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,21 @@ | ||
import React from 'react'; | ||
import { expect } from 'chai'; | ||
import { mount } from '../'; | ||
import { describeWithDOM } from '../describeWithDOM'; | ||
|
||
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 called | ||
expect(true).to.equal(false); | ||
}); | ||
}); | ||
|
||
describeWithDOM('will still call describeWithDOM 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