Skip to content

Instantly share code, notes, and snippets.

@why-jay
Created June 26, 2015 04:06
Show Gist options
  • Select an option

  • Save why-jay/aefc5405f27e20b08ebc to your computer and use it in GitHub Desktop.

Select an option

Save why-jay/aefc5405f27e20b08ebc to your computer and use it in GitHub Desktop.

Revisions

  1. YJ Yang created this gist Jun 26, 2015.
    4 changes: 4 additions & 0 deletions Error message
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    Using Jest CLI v0.4.13
    FAIL __tests__/foo-test.js (0.896s)
    ● foo() › it should throw
    - Expected function to throw an exception.
    5 changes: 5 additions & 0 deletions Versions
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    node v0.12.2
    npm v2.11.2

    babel-jest v5.3.0
    jest-cli v0.4.13
    11 changes: 11 additions & 0 deletions foo-test.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    // __tests__/foo-test.js

    import foo from '../src/foo.js';

    describe('foo()', () => {
    it('should throw', () => {
    expect(() => {
    foo();
    }).toThrow();
    });
    });
    5 changes: 5 additions & 0 deletions foo.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    // src/foo.js

    export default function foo() {
    throw new Error();
    }
    15 changes: 15 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    {
    "devDependencies": {
    "babel-jest": "*",
    "jest-cli": "*"
    },
    "scripts": {
    "test": "jest"
    },
    "jest": {
    "scriptPreprocessor": "<rootDir>/node_modules/babel-jest",
    "testFileExtensions": ["es6", "js"],
    "moduleFileExtensions": ["js", "json", "es6"],
    "unmockedModulePathPatterns": ["lodash"]
    }
    }