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
import {theDay} from 'doom-scheduler' | |
import {Launch} from './rocket-silo'; | |
theDay | |
.then(Launch) | |
.then( () => alert(' :) '), | |
() => alert(' :( next time, you know...'); |
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
export const theDay = Promise.resolve(); |
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
import {Launch} from './rocket-silo'; | |
import {theDay} from 'doom-scheduler' | |
import 'rocket-silo'; | |
jest.mock('./rocket-silo'); // mocking something we already imported!!! | |
jest.mock('doom-scheduler'); | |
theDay.mockResolvedValue("comming!"); | |
expect(Launch).toHaveBeenCalled(); |
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
import mockery from 'mockery'; | |
import sinon from 'sinon'; | |
//import {Launch} from './rocket-silo'; // you cannot use imports | |
//import {theDay} from 'doom-scheduler' | |
mockery.registerMock('./rocket-silo', { | |
Launch: sinon.stub() | |
}); | |
mockery.registerMock('doom-scheduler', { |
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
import proxyquire from 'proxyquire'; | |
import sinon from 'sinon'; | |
const Launch= sinon.stub() | |
const case = proxyquire.load('./dooms-day.js',{ | |
'./rocket-silo', { Launch }, | |
'doom-scheduler', { theDay: Promise.resolve() | |
}); |
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
import td from 'testdouble'; | |
const {Launch} = td.replace('./rocket-silo'); // automock | |
const scheduler = td.replace('doom-scheduler', { theDay: Promise.resolve() }) | |
require('./dooms-day.js'); | |
td.verify(Launch()); |
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
import rewiremock from 'rewiremock'; | |
import {Launch} from './rocket-silo'; | |
import {theDay} from 'doom-scheduler' | |
import 'rocket-silo'; | |
// prev jest.mock('doom-scheduler'); | |
rewiremock('./rocket-silo').mockThrough(); | |
rewiremock('doom-scheduler').mockThrough(); | |
theDay.resolves("comming!"); // sinon |
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
import rewiremock from 'rewiremock'; | |
import sinon from 'sinon'; | |
// mockery.registerMock('./rocket-silo', { | |
// Launch: sinon.stub() | |
// }); | |
rewiremock('./rocket-silo').with({ | |
Launch: sinon.stub() | |
}); |
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
import rewiremock from 'rewiremock'; | |
import sinon from 'sinon'; | |
const Launch = sinon.stub() | |
// const case = proxyquire.load('./dooms-day.js',{ | |
const case = rewiremock.proxy('./dooms-day.js',{ | |
'./rocket-silo': { Launch }, | |
'doom-scheduler': { theDay: Promise.resolve()} | |
}); |
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
import rewiremock from 'rewiremock'; | |
const {Launch} = rewiremock('./rocket-silo').mockThrough(); // automock | |
const scheduler = rewiremock('doom-scheduler').with({ theDay: Promise.resolve() }) | |
rewiremock.proxy('./dooms-day.js'); | |
expect(Launch).toHaveBeenCalled(); |