Skip to content

Commit

Permalink
Reset example.txt content after tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottsj committed Jun 7, 2020
1 parent 0422f88 commit db1b80c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion example/example.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ const path = require('path');
const webpack = require('webpack');
const config = require('./webpack.config');

const EXAMPLE_TXT_PATH = path.resolve(__dirname, './example.txt');

let exampleTxtContent;

beforeAll(() => {
exampleTxtContent = fs.readFileSync(EXAMPLE_TXT_PATH);
});

afterAll(() => {
fs.writeFileSync(EXAMPLE_TXT_PATH, exampleTxtContent);
});

it('invalidates webpack build upon changing an inline imported file', () =>
new Promise((resolve, reject) => {
const compiler = webpack(config);
Expand All @@ -16,7 +28,7 @@ it('invalidates webpack build upon changing an inline imported file', () =>
}
if (initialBuild) {
// Modify example.txt to trigger another build
fs.appendFileSync(path.resolve(__dirname, './example.txt'), 'foo\n');
fs.appendFileSync(EXAMPLE_TXT_PATH, 'foo\n');
initialBuild = false;
return;
}
Expand Down

0 comments on commit db1b80c

Please sign in to comment.