Skip to content

Commit

Permalink
adds .only tests and modified package.json test runs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate Piche committed Jan 19, 2016
1 parent 803b114 commit f73d3e7
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ node_modules
# Jetbrains IDEs
.idea

# vim swp files
*.swp

/build
_book
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 react@0.13",
"react:14": "npm run react:clean && npm i react@0.14 react-dom@0.14 react-addons-test-utils@0.14",
Expand Down
21 changes: 0 additions & 21 deletions src/__tests__/describeWithDOM-spec.js

This file was deleted.

19 changes: 19 additions & 0 deletions src/__tests__/describeWithDOM/describeWithDOMOnly-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { expect } from 'chai';
import { describeWithDOM } from '../../describeWithDOM';

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);
});
});
});
});
19 changes: 19 additions & 0 deletions src/__tests__/describeWithDOM/describeWithDOMSkip-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { expect } from 'chai';
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 run
expect(true).to.equal(false);
});
});

describeWithDOM('will still call describeWithDOM tests without .skip', () => {
it('will run this test', () => {
expect(true).to.equal(true);
});
});
});
});
8 changes: 4 additions & 4 deletions src/describeWithDOM.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
let jsdom;

try {
require('jsdom'); // could throw
jsdom = require('mocha-jsdom');
require('jsdom'); // could throw
jsdom = require('mocha-jsdom');
} catch (e) {
// jsdom is not supported...
// jsdom is not supported...
}

export function describeWithDOM(a, b) {
describe('(uses jsdom)', () => {
if (typeof jsdom === 'function') {
if (typeof jsdom === 'function') {
jsdom();
describe(a, b);
} else {
Expand Down

0 comments on commit f73d3e7

Please sign in to comment.