Skip to content

Instantly share code, notes, and snippets.

@keithstric
Last active February 17, 2020 16:05
Show Gist options
  • Save keithstric/af57c019c19ec4abe201de668286e0f0 to your computer and use it in GitHub Desktop.
Save keithstric/af57c019c19ec4abe201de668286e0f0 to your computer and use it in GitHub Desktop.
Adventures in Unit Testing 2
const someFunction = require('./index');
const rewire = require('rewire');
let app;
beforeEach(() => {
someFunction();
app = rewire('./index.js');
});
test('it should increment evtCount', () => {
const evtCount = app.__get__('evtCount');
const somePrivateFunc = app.__get__('somePrivateFunction');
somePrivateFunc();
expect(evtCount).toEqual(1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment