Created
December 17, 2018 16:58
-
-
Save pvdlg/6bd01c2d66350e8bb2f25aba64ad8859 to your computer and use it in GitHub Desktop.
Reduced test case for https://github.com/avajs/ava/issues/1999 - v2
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
let state = 0; | |
console.log('Load module') | |
async function increment() { | |
state = state + 1; | |
} | |
function getState() { | |
return state; | |
} | |
module.exports = {increment, getState}; |
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
// This file should be in test.js | |
import test from 'ava'; | |
import clearModule from 'clear-module'; | |
test.beforeEach(t => { | |
clearModule('.'); | |
t.context.m = require('.'); | |
}); | |
test('Test 1', async t => { | |
await t.context.m.increment(); | |
t.is(t.context.m.getState(), 1); | |
}); | |
test('Test 2', async t => { | |
await t.context.m.increment(); | |
t.is(t.context.m.getState(), 1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment