From 927bf45f1c7666e42ae8c4c390cc726a75cab903 Mon Sep 17 00:00:00 2001 From: Heinrich Filter Date: Tue, 13 Sep 2016 17:39:35 +0200 Subject: [PATCH] #1944 Converting tests from Mocha to Jest Added Jest dependencies Removed expect from files Updated mocks to use `jest.fn()` Current `expect.spyOn` replacement can be improved on TODO: Fix linter not to complain about using `console` --- package.json | 7 +- test/.eslintrc | 2 +- test/applyMiddleware.spec.js | 11 +- test/bindActionCreators.spec.js | 1 - test/combineReducers.spec.js | 67 +++++++----- test/compose.spec.js | 1 - test/createStore.spec.js | 181 ++++++++++++++++---------------- test/typescript.spec.js | 2 +- test/utils/warning.spec.js | 14 +-- 9 files changed, 152 insertions(+), 134 deletions(-) diff --git a/package.json b/package.json index 3513c7f492..7576b068c0 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "lint": "npm run lint:src && npm run lint:examples", "lint:src": "eslint src test build", "lint:examples": "eslint examples", - "test": "cross-env BABEL_ENV=commonjs mocha --compilers js:babel-register --recursive", + "test": "jest", "test:watch": "npm test -- --watch", "test:cov": "cross-env BABEL_ENV=commonjs babel-node $(npm bin)/isparta cover $(npm bin)/_mocha -- --recursive", "test:examples": "cross-env BABEL_ENV=commonjs babel-node examples/testAll.js", @@ -73,6 +73,7 @@ "babel-cli": "^6.3.15", "babel-core": "^6.3.15", "babel-eslint": "^4.1.6", + "babel-jest": "^15.0.0", "babel-loader": "^6.2.0", "babel-plugin-check-es2015-constants": "^6.3.13", "babel-plugin-transform-es2015-arrow-functions": "^6.3.13", @@ -105,6 +106,7 @@ "gitbook-cli": "^2.3.0", "glob": "^6.0.4", "isparta": "^4.0.0", + "jest": "^15.1.1", "mocha": "^2.2.5", "rimraf": "^2.3.4", "rxjs": "^5.0.0-beta.6", @@ -125,5 +127,8 @@ "transform": [ "loose-envify" ] + }, + "jest": { + "testRegex": "(/test/.*\\.spec.js)$" } } diff --git a/test/.eslintrc b/test/.eslintrc index 7eeefc33b6..55f121d152 100644 --- a/test/.eslintrc +++ b/test/.eslintrc @@ -1,5 +1,5 @@ { "env": { - "mocha": true + "jest": true } } diff --git a/test/applyMiddleware.spec.js b/test/applyMiddleware.spec.js index cb12ab8514..fa5e0f11f0 100644 --- a/test/applyMiddleware.spec.js +++ b/test/applyMiddleware.spec.js @@ -1,4 +1,3 @@ -import expect from 'expect' import { createStore, applyMiddleware } from '../src/index' import * as reducers from './helpers/reducers' import { addTodo, addTodoAsync, addTodoIfEmpty } from './helpers/actionCreators' @@ -13,15 +12,15 @@ describe('applyMiddleware', () => { } } - const spy = expect.createSpy(() => {}) + const spy = jest.fn(() => {}) const store = applyMiddleware(test(spy), thunk)(createStore)(reducers.todos) store.dispatch(addTodo('Use Redux')) store.dispatch(addTodo('Flux FTW!')) - expect(spy.calls.length).toEqual(1) + expect(spy.mock.calls.length).toEqual(1) - expect(Object.keys(spy.calls[0].arguments[0])).toEqual([ + expect(Object.keys(spy.mock.calls[0][0])).toEqual([ 'getState', 'dispatch' ]) @@ -37,11 +36,11 @@ describe('applyMiddleware', () => { } } - const spy = expect.createSpy(() => {}) + const spy = jest.fn(() => {}) const store = applyMiddleware(test(spy), thunk)(createStore)(reducers.todos) return store.dispatch(addTodoAsync('Use Redux')).then(() => { - expect(spy.calls.length).toEqual(2) + expect(spy.mock.calls.length).toEqual(2) }) }) diff --git a/test/bindActionCreators.spec.js b/test/bindActionCreators.spec.js index f9fcc5c264..f4a8cb2b44 100644 --- a/test/bindActionCreators.spec.js +++ b/test/bindActionCreators.spec.js @@ -1,4 +1,3 @@ -import expect from 'expect' import { bindActionCreators, createStore } from '../src' import { todos } from './helpers/reducers' import * as actionCreators from './helpers/actionCreators' diff --git a/test/combineReducers.spec.js b/test/combineReducers.spec.js index a373db4e76..29fc382c2a 100644 --- a/test/combineReducers.spec.js +++ b/test/combineReducers.spec.js @@ -1,4 +1,3 @@ -import expect from 'expect' import { combineReducers } from '../src' import createStore, { ActionTypes } from '../src/createStore' @@ -32,21 +31,24 @@ describe('Utils', () => { }) it('warns if a reducer prop is undefined', () => { - const spy = expect.spyOn(console, 'error') + const preSpy = console.error + const spy = jest.fn(() => {}) + console.error = spy let isNotDefined combineReducers({ isNotDefined }) - expect(spy.calls[0].arguments[0]).toMatch( + expect(spy.mock.calls[0][0]).toMatch( /No reducer provided for key "isNotDefined"/ ) - spy.reset() + spy.mockClear() combineReducers({ thing: undefined }) - expect(spy.calls[0].arguments[0]).toMatch( + expect(spy.mock.calls[0][0]).toMatch( /No reducer provided for key "thing"/ ) - spy.restore() + spy.mockClear() + console.error = preSpy }) it('throws an error if a reducer returns undefined handling an action', () => { @@ -166,7 +168,7 @@ describe('Utils', () => { }) const initialState = reducer(undefined, '@@INIT') - expect(reducer(initialState, { type: 'increment' })).toNotBe(initialState) + expect(reducer(initialState, { type: 'increment' })).not.toBe(initialState) }) it('throws an error on first call if a reducer attempts to handle a private action', () => { @@ -191,17 +193,24 @@ describe('Utils', () => { }) it('warns if no reducers are passed to combineReducers', () => { - const spy = expect.spyOn(console, 'error') + const preSpy = console.error + const spy = jest.fn(() => {}) + console.error = spy + const reducer = combineReducers({ }) reducer({ }) - expect(spy.calls[0].arguments[0]).toMatch( + expect(spy.mock.calls[0][0]).toMatch( /Store does not have a valid reducer/ ) - spy.restore() + spy.mockClear() + console.error = preSpy }) it('warns if input state does not match reducer shape', () => { - const spy = expect.spyOn(console, 'error') + const preSpy = console.error + const spy = jest.fn(() => {}) + console.error = spy + const reducer = combineReducers({ foo(state = { bar: 1 }) { return state @@ -212,69 +221,75 @@ describe('Utils', () => { }) reducer() - expect(spy.calls.length).toBe(0) + expect(spy.mock.calls.length).toBe(0) reducer({ foo: { bar: 2 } }) - expect(spy.calls.length).toBe(0) + expect(spy.mock.calls.length).toBe(0) reducer({ foo: { bar: 2 }, baz: { qux: 4 } }) - expect(spy.calls.length).toBe(0) + expect(spy.mock.calls.length).toBe(0) createStore(reducer, { bar: 2 }) - expect(spy.calls[0].arguments[0]).toMatch( + expect(spy.mock.calls[0][0]).toMatch( /Unexpected key "bar".*createStore.*instead: "foo", "baz"/ ) createStore(reducer, { bar: 2, qux: 4, thud: 5 }) - expect(spy.calls[1].arguments[0]).toMatch( + expect(spy.mock.calls[1][0]).toMatch( /Unexpected keys "qux", "thud".*createStore.*instead: "foo", "baz"/ ) createStore(reducer, 1) - expect(spy.calls[2].arguments[0]).toMatch( + expect(spy.mock.calls[2][0]).toMatch( /createStore has unexpected type of "Number".*keys: "foo", "baz"/ ) reducer({ corge: 2 }) - expect(spy.calls[3].arguments[0]).toMatch( + expect(spy.mock.calls[3][0]).toMatch( /Unexpected key "corge".*reducer.*instead: "foo", "baz"/ ) reducer({ fred: 2, grault: 4 }) - expect(spy.calls[4].arguments[0]).toMatch( + expect(spy.mock.calls[4][0]).toMatch( /Unexpected keys "fred", "grault".*reducer.*instead: "foo", "baz"/ ) reducer(1) - expect(spy.calls[5].arguments[0]).toMatch( + expect(spy.mock.calls[5][0]).toMatch( /reducer has unexpected type of "Number".*keys: "foo", "baz"/ ) - spy.restore() + spy.mockClear() + console.error = preSpy }) it('only warns for unexpected keys once', () => { - const spy = expect.spyOn(console, 'error') + const preSpy = console.error + const spy = jest.fn(() => {}) + console.error = spy + const foo = (state = { foo: 1 }) => state const bar = (state = { bar: 2 }) => state - expect(spy.calls.length).toBe(0) + expect(spy.mock.calls.length).toBe(0) const reducer = combineReducers({ foo, bar }) const state = { foo: 1, bar: 2, qux: 3 } reducer(state, {}) reducer(state, {}) reducer(state, {}) reducer(state, {}) - expect(spy.calls.length).toBe(1) + expect(spy.mock.calls.length).toBe(1) reducer({ ...state, baz: 5 }, {}) reducer({ ...state, baz: 5 }, {}) reducer({ ...state, baz: 5 }, {}) reducer({ ...state, baz: 5 }, {}) - expect(spy.calls.length).toBe(2) - spy.restore() + expect(spy.mock.calls.length).toBe(2) + + spy.mockClear() + console.error = preSpy }) }) }) diff --git a/test/compose.spec.js b/test/compose.spec.js index c0a6a9ce13..49e4a2616f 100644 --- a/test/compose.spec.js +++ b/test/compose.spec.js @@ -1,4 +1,3 @@ -import expect from 'expect' import { compose } from '../src' describe('Utils', () => { diff --git a/test/createStore.spec.js b/test/createStore.spec.js index 369bb98af3..12b78d3460 100644 --- a/test/createStore.spec.js +++ b/test/createStore.spec.js @@ -1,4 +1,3 @@ -import expect from 'expect' import { createStore, combineReducers } from '../src/index' import { addTodo, dispatchInMiddle, throwError, unknownAction } from './helpers/actionCreators' import * as reducers from './helpers/reducers' @@ -32,7 +31,7 @@ describe('createStore', () => { expect(() => createStore(() => {}) - ).toNotThrow() + ).not.toThrow() }) it('passes the initial action and the initial state', () => { @@ -192,55 +191,55 @@ describe('createStore', () => { it('supports multiple subscriptions', () => { const store = createStore(reducers.todos) - const listenerA = expect.createSpy(() => {}) - const listenerB = expect.createSpy(() => {}) + const listenerA = jest.fn(() => {}) + const listenerB = jest.fn(() => {}) let unsubscribeA = store.subscribe(listenerA) store.dispatch(unknownAction()) - expect(listenerA.calls.length).toBe(1) - expect(listenerB.calls.length).toBe(0) + expect(listenerA.mock.calls.length).toBe(1) + expect(listenerB.mock.calls.length).toBe(0) store.dispatch(unknownAction()) - expect(listenerA.calls.length).toBe(2) - expect(listenerB.calls.length).toBe(0) + expect(listenerA.mock.calls.length).toBe(2) + expect(listenerB.mock.calls.length).toBe(0) const unsubscribeB = store.subscribe(listenerB) - expect(listenerA.calls.length).toBe(2) - expect(listenerB.calls.length).toBe(0) + expect(listenerA.mock.calls.length).toBe(2) + expect(listenerB.mock.calls.length).toBe(0) store.dispatch(unknownAction()) - expect(listenerA.calls.length).toBe(3) - expect(listenerB.calls.length).toBe(1) + expect(listenerA.mock.calls.length).toBe(3) + expect(listenerB.mock.calls.length).toBe(1) unsubscribeA() - expect(listenerA.calls.length).toBe(3) - expect(listenerB.calls.length).toBe(1) + expect(listenerA.mock.calls.length).toBe(3) + expect(listenerB.mock.calls.length).toBe(1) store.dispatch(unknownAction()) - expect(listenerA.calls.length).toBe(3) - expect(listenerB.calls.length).toBe(2) + expect(listenerA.mock.calls.length).toBe(3) + expect(listenerB.mock.calls.length).toBe(2) unsubscribeB() - expect(listenerA.calls.length).toBe(3) - expect(listenerB.calls.length).toBe(2) + expect(listenerA.mock.calls.length).toBe(3) + expect(listenerB.mock.calls.length).toBe(2) store.dispatch(unknownAction()) - expect(listenerA.calls.length).toBe(3) - expect(listenerB.calls.length).toBe(2) + expect(listenerA.mock.calls.length).toBe(3) + expect(listenerB.mock.calls.length).toBe(2) unsubscribeA = store.subscribe(listenerA) - expect(listenerA.calls.length).toBe(3) - expect(listenerB.calls.length).toBe(2) + expect(listenerA.mock.calls.length).toBe(3) + expect(listenerB.mock.calls.length).toBe(2) store.dispatch(unknownAction()) - expect(listenerA.calls.length).toBe(4) - expect(listenerB.calls.length).toBe(2) + expect(listenerA.mock.calls.length).toBe(4) + expect(listenerB.mock.calls.length).toBe(2) }) it('only removes listener once when unsubscribe is called', () => { const store = createStore(reducers.todos) - const listenerA = expect.createSpy(() => {}) - const listenerB = expect.createSpy(() => {}) + const listenerA = jest.fn(() => {}) + const listenerB = jest.fn(() => {}) const unsubscribeA = store.subscribe(listenerA) store.subscribe(listenerB) @@ -249,13 +248,13 @@ describe('createStore', () => { unsubscribeA() store.dispatch(unknownAction()) - expect(listenerA.calls.length).toBe(0) - expect(listenerB.calls.length).toBe(1) + expect(listenerA.mock.calls.length).toBe(0) + expect(listenerB.mock.calls.length).toBe(1) }) it('only removes relevant listener when unsubscribe is called', () => { const store = createStore(reducers.todos) - const listener = expect.createSpy(() => {}) + const listener = jest.fn(() => {}) store.subscribe(listener) const unsubscribeSecond = store.subscribe(listener) @@ -264,14 +263,14 @@ describe('createStore', () => { unsubscribeSecond() store.dispatch(unknownAction()) - expect(listener.calls.length).toBe(1) + expect(listener.mock.calls.length).toBe(1) }) it('supports removing a subscription within a subscription', () => { const store = createStore(reducers.todos) - const listenerA = expect.createSpy(() => {}) - const listenerB = expect.createSpy(() => {}) - const listenerC = expect.createSpy(() => {}) + const listenerA = jest.fn(() => {}) + const listenerB = jest.fn(() => {}) + const listenerC = jest.fn(() => {}) store.subscribe(listenerA) const unSubB = store.subscribe(() => { @@ -283,9 +282,9 @@ describe('createStore', () => { store.dispatch(unknownAction()) store.dispatch(unknownAction()) - expect(listenerA.calls.length).toBe(2) - expect(listenerB.calls.length).toBe(1) - expect(listenerC.calls.length).toBe(2) + expect(listenerA.mock.calls.length).toBe(2) + expect(listenerB.mock.calls.length).toBe(1) + expect(listenerC.mock.calls.length).toBe(2) }) it('delays unsubscribe until the end of current dispatch', () => { @@ -296,9 +295,9 @@ describe('createStore', () => { unsubscribe => unsubscribe() ) - const listener1 = expect.createSpy(() => {}) - const listener2 = expect.createSpy(() => {}) - const listener3 = expect.createSpy(() => {}) + const listener1 = jest.fn(() => {}) + const listener2 = jest.fn(() => {}) + const listener3 = jest.fn(() => {}) unsubscribeHandles.push(store.subscribe(() => listener1())) unsubscribeHandles.push(store.subscribe(() => { @@ -308,22 +307,22 @@ describe('createStore', () => { unsubscribeHandles.push(store.subscribe(() => listener3())) store.dispatch(unknownAction()) - expect(listener1.calls.length).toBe(1) - expect(listener2.calls.length).toBe(1) - expect(listener3.calls.length).toBe(1) + expect(listener1.mock.calls.length).toBe(1) + expect(listener2.mock.calls.length).toBe(1) + expect(listener3.mock.calls.length).toBe(1) store.dispatch(unknownAction()) - expect(listener1.calls.length).toBe(1) - expect(listener2.calls.length).toBe(1) - expect(listener3.calls.length).toBe(1) + expect(listener1.mock.calls.length).toBe(1) + expect(listener2.mock.calls.length).toBe(1) + expect(listener3.mock.calls.length).toBe(1) }) it('delays subscribe until the end of current dispatch', () => { const store = createStore(reducers.todos) - const listener1 = expect.createSpy(() => {}) - const listener2 = expect.createSpy(() => {}) - const listener3 = expect.createSpy(() => {}) + const listener1 = jest.fn(() => {}) + const listener2 = jest.fn(() => {}) + const listener3 = jest.fn(() => {}) let listener3Added = false const maybeAddThirdListener = () => { @@ -340,56 +339,56 @@ describe('createStore', () => { }) store.dispatch(unknownAction()) - expect(listener1.calls.length).toBe(1) - expect(listener2.calls.length).toBe(1) - expect(listener3.calls.length).toBe(0) + expect(listener1.mock.calls.length).toBe(1) + expect(listener2.mock.calls.length).toBe(1) + expect(listener3.mock.calls.length).toBe(0) store.dispatch(unknownAction()) - expect(listener1.calls.length).toBe(2) - expect(listener2.calls.length).toBe(2) - expect(listener3.calls.length).toBe(1) + expect(listener1.mock.calls.length).toBe(2) + expect(listener2.mock.calls.length).toBe(2) + expect(listener3.mock.calls.length).toBe(1) }) it('uses the last snapshot of subscribers during nested dispatch', () => { const store = createStore(reducers.todos) - const listener1 = expect.createSpy(() => {}) - const listener2 = expect.createSpy(() => {}) - const listener3 = expect.createSpy(() => {}) - const listener4 = expect.createSpy(() => {}) + const listener1 = jest.fn(() => {}) + const listener2 = jest.fn(() => {}) + const listener3 = jest.fn(() => {}) + const listener4 = jest.fn(() => {}) let unsubscribe4 const unsubscribe1 = store.subscribe(() => { listener1() - expect(listener1.calls.length).toBe(1) - expect(listener2.calls.length).toBe(0) - expect(listener3.calls.length).toBe(0) - expect(listener4.calls.length).toBe(0) + expect(listener1.mock.calls.length).toBe(1) + expect(listener2.mock.calls.length).toBe(0) + expect(listener3.mock.calls.length).toBe(0) + expect(listener4.mock.calls.length).toBe(0) unsubscribe1() unsubscribe4 = store.subscribe(listener4) store.dispatch(unknownAction()) - expect(listener1.calls.length).toBe(1) - expect(listener2.calls.length).toBe(1) - expect(listener3.calls.length).toBe(1) - expect(listener4.calls.length).toBe(1) + expect(listener1.mock.calls.length).toBe(1) + expect(listener2.mock.calls.length).toBe(1) + expect(listener3.mock.calls.length).toBe(1) + expect(listener4.mock.calls.length).toBe(1) }) store.subscribe(listener2) store.subscribe(listener3) store.dispatch(unknownAction()) - expect(listener1.calls.length).toBe(1) - expect(listener2.calls.length).toBe(2) - expect(listener3.calls.length).toBe(2) - expect(listener4.calls.length).toBe(1) + expect(listener1.mock.calls.length).toBe(1) + expect(listener2.mock.calls.length).toBe(2) + expect(listener3.mock.calls.length).toBe(2) + expect(listener4.mock.calls.length).toBe(1) unsubscribe4() store.dispatch(unknownAction()) - expect(listener1.calls.length).toBe(1) - expect(listener2.calls.length).toBe(3) - expect(listener3.calls.length).toBe(3) - expect(listener4.calls.length).toBe(1) + expect(listener1.mock.calls.length).toBe(1) + expect(listener2.mock.calls.length).toBe(3) + expect(listener3.mock.calls.length).toBe(3) + expect(listener4.mock.calls.length).toBe(1) }) it('provides an up-to-date state when a subscriber is notified', done => { @@ -410,7 +409,7 @@ describe('createStore', () => { const store = createStore(reducers.todos) expect(() => store.dispatch(unknownAction()) - ).toNotThrow() + ).not.toThrow() function AwesomeMap() { } [ null, undefined, 42, 'hey', new AwesomeMap() ].forEach(nonObject => @@ -461,7 +460,7 @@ describe('createStore', () => { expect(() => store.dispatch(unknownAction()) - ).toNotThrow() + ).not.toThrow() }) it('throws if action type is missing', () => { @@ -482,16 +481,16 @@ describe('createStore', () => { const store = createStore(reducers.todos) expect(() => store.dispatch({ type: false }) - ).toNotThrow() + ).not.toThrow() expect(() => store.dispatch({ type: 0 }) - ).toNotThrow() + ).not.toThrow() expect(() => store.dispatch({ type: null }) - ).toNotThrow() + ).not.toThrow() expect(() => store.dispatch({ type: '' }) - ).toNotThrow() + ).not.toThrow() }) it('accepts enhancer as the third argument', () => { @@ -503,14 +502,14 @@ describe('createStore', () => { const vanillaStore = vanillaCreateStore(...args) return { ...vanillaStore, - dispatch: expect.createSpy(vanillaStore.dispatch).andCallThrough() + dispatch: jest.fn(vanillaStore.dispatch) } } const store = createStore(reducers.todos, emptyArray, spyEnhancer) const action = addTodo('Hello') store.dispatch(action) - expect(store.dispatch).toHaveBeenCalledWith(action) + expect(store.dispatch).toBeCalledWith(action) expect(store.getState()).toEqual([ { id: 1, @@ -527,14 +526,14 @@ describe('createStore', () => { const vanillaStore = vanillaCreateStore(...args) return { ...vanillaStore, - dispatch: expect.createSpy(vanillaStore.dispatch).andCallThrough() + dispatch: jest.fn(vanillaStore.dispatch) } } const store = createStore(reducers.todos, spyEnhancer) const action = addTodo('Hello') store.dispatch(action) - expect(store.dispatch).toHaveBeenCalledWith(action) + expect(store.dispatch).toBeCalledWith(action) expect(store.getState()).toEqual([ { id: 1, @@ -562,23 +561,23 @@ describe('createStore', () => { expect(() => createStore(reducers.todos, undefined, undefined) - ).toNotThrow() + ).not.toThrow() expect(() => createStore(reducers.todos, undefined, x => x) - ).toNotThrow() + ).not.toThrow() expect(() => createStore(reducers.todos, x => x) - ).toNotThrow() + ).not.toThrow() expect(() => createStore(reducers.todos, []) - ).toNotThrow() + ).not.toThrow() expect(() => createStore(reducers.todos, {}) - ).toNotThrow() + ).not.toThrow() }) it('throws if nextReducer is not a function', () => { @@ -590,7 +589,7 @@ describe('createStore', () => { expect(() => store.replaceReducer(() => {}) - ).toNotThrow() + ).not.toThrow() }) it('throws if listener is not a function', () => { @@ -640,7 +639,7 @@ describe('createStore', () => { expect(function () { obs.subscribe({}) - }).toNotThrow() + }).not.toThrow() }) it('should return a subscription object when subscribed', () => { diff --git a/test/typescript.spec.js b/test/typescript.spec.js index 5d0bc28f0c..3464b0399d 100644 --- a/test/typescript.spec.js +++ b/test/typescript.spec.js @@ -2,7 +2,7 @@ import * as tt from 'typescript-definition-tester' describe('TypeScript definitions', function () { - this.timeout(0) + //this.timeout(0) it('should compile against index.d.ts', (done) => { tt.compileDirectory( diff --git a/test/utils/warning.spec.js b/test/utils/warning.spec.js index e8e1316340..3d21f0f073 100644 --- a/test/utils/warning.spec.js +++ b/test/utils/warning.spec.js @@ -1,15 +1,17 @@ -import expect from 'expect' import warning from '../../src/utils/warning' describe('Utils', () => { describe('warning', () => { it('calls console.error when available', () => { - const spy = expect.spyOn(console, 'error') + const preSpy = console.error + const spy = jest.fn(() => {}) + console.error = spy try { warning('Test') - expect(spy.calls[0].arguments[0]).toBe('Test') + expect(spy.mock.calls[0][0]).toBe('Test') } finally { - spy.restore() + spy.mockClear() + console.error = preSpy } }) @@ -17,7 +19,7 @@ describe('Utils', () => { const realConsole = global.console Object.defineProperty(global, 'console', { value: {} }) try { - expect(() => warning('Test')).toNotThrow() + expect(() => warning('Test')).not.toThrow() } finally { Object.defineProperty(global, 'console', { value: realConsole }) } @@ -27,7 +29,7 @@ describe('Utils', () => { const realConsole = global.console Object.defineProperty(global, 'console', { value: undefined }) try { - expect(() => warning('Test')).toNotThrow() + expect(() => warning('Test')).not.toThrow() } finally { Object.defineProperty(global, 'console', { value: realConsole }) }