This file contains hidden or 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 { stub } from 'sinon'; | |
| import { expect } from 'chai'; | |
| describe('runnable.ts', () => { | |
| let target = '../src/runnable.ts'; | |
| beforeEach(() => { | |
| stub(console, 'log'); | |
| }); |
This file contains hidden or 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
| if (process.env.IS_GOODBYE === 'true') { | |
| console.log('goodbye world!'); | |
| } else { | |
| console.log('hello world'); | |
| } |
This file contains hidden or 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 * as functionToMock from '../src/other-function'; | |
| import { myFunction } from '../src/my-function'; | |
| import { stub } from 'sinon'; | |
| describe('myFunction()', () => { | |
| beforeEach(() => { | |
| stub(functionToMock, 'otherFunction').returns('expected result' as any); | |
| }); | |
| it('should return otherFunction result', () => { |
This file contains hidden or 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 { otherFunction } from './other-function'; | |
| export function myFunction() { | |
| return otherFunction(123); | |
| } |
This file contains hidden or 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 * as classToMock from '../src/my-class'; | |
| import { getInstance } from '../src/get-instance'; | |
| import { stub } from 'sinon'; | |
| describe('getInstance()', () => { | |
| const mockedInstance = { | |
| info: 'MyClass instance', | |
| }; | |
| beforeEach(() => { |
This file contains hidden or 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 { MyClass } from './my-class'; | |
| export function getInstance() { | |
| return new MyClass(123); | |
| } |
This file contains hidden or 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 { stub, SinonStub } from 'sinon'; | |
| import * as server from '../src/server'; | |
| // First describe, class name | |
| describe('index.ts', () => { | |
| let start: SinonStub; | |
| // Before each to bootstrap stubs, where all the methods that could be called are stubbeds | |
| beforeEach(() => { | |
| start = sinon.stub(server, 'start'); |
This file contains hidden or 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 { stub, SinonStub } from 'sinon'; | |
| // First describe, class name | |
| describe('MyClass', () => { | |
| let service: MyService; | |
| let target: MyClass; | |
| // Class describe beforeEach, class bootstrap | |
| beforeEach(() => { | |
| service = {} as any; |
This file contains hidden or 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 'reflect-metadata'; | |
| import { use } from 'chai'; | |
| import { restore } from 'sinon'; | |
| import sinonChai = require('sinon-chai'); | |
| use(sinonChai); | |
| afterEach(() => { | |
| restore(); | |
| }); |
This file contains hidden or 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
| var gulp = require('gulp'); | |
| var del = require('del'); | |
| gulp.task('default', function () { | |
| return del([ | |
| 'build/' | |
| ]); | |
| }); |