Skip to content

Instantly share code, notes, and snippets.

@Vittly
Created April 11, 2019 17:36
Show Gist options
  • Save Vittly/bf4cdfe21ed657b4a61879d77f9fc21e to your computer and use it in GitHub Desktop.
Save Vittly/bf4cdfe21ed657b4a61879d77f9fc21e to your computer and use it in GitHub Desktop.
ts-mock-imports issue file
export function storiesOf(): string;
Object.defineProperty(exports, "storiesOf", {
enumerable: true,
get: function() {
return () => 'abc';
}
});
import { assert } from 'chai';
import { describe, it } from 'mocha';
import { ImportMock } from 'ts-mock-imports';
import * as Module from './bar';
ImportMock.mockFunction(Module, 'storiesOf', 'xyz');
import fooFn from './foo'; // which in fact should call Module.storiesOf
describe('foo', () => {
it('should do the magic', () => {
assert.strictEqual(fooFn(), 'xyz');
});
});
import * as Module from './bar';
export default function() {
return Module.storiesOf();
}
mocha --require ts-node/register *.test.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment