Skip to content

Instantly share code, notes, and snippets.

@pvdlg
Created December 17, 2018 16:58
Show Gist options
  • Save pvdlg/6bd01c2d66350e8bb2f25aba64ad8859 to your computer and use it in GitHub Desktop.
Save pvdlg/6bd01c2d66350e8bb2f25aba64ad8859 to your computer and use it in GitHub Desktop.
Reduced test case for https://github.com/avajs/ava/issues/1999 - v2
let state = 0;
console.log('Load module')
async function increment() {
state = state + 1;
}
function getState() {
return state;
}
module.exports = {increment, getState};
// 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