Skip to content

Commit

Permalink
fix: prevent example tests from getting stuck on error
Browse files Browse the repository at this point in the history
  • Loading branch information
Knagis committed Apr 14, 2023
1 parent 064f300 commit 24c37a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"standard-version": "^9.3.0",
"style-loader": "2.0.0",
"typescript": "4.1.3",
"webpack": "5.24.3",
"webpack": "^5.79.0",
"webpack-cli": "4.5.0",
"webpack-recompilation-simulator": "3.2.0"
},
Expand Down
32 changes: 18 additions & 14 deletions spec/example.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,24 @@ function runExample (exampleName, done) {
}

webpack(options, (err, stats) => {
expect(err).toBeFalsy();
expect(stats.compilation.errors).toEqual([]);

const dircompare = require('dir-compare');
const res = dircompare.compareSync(fixturePath, exampleOutput, { compareSize: true });

res.diffSet.filter(diff => diff.state === 'distinct').forEach(diff => {
const file1Contents = fs.readFileSync(path.join(diff.path1, diff.name1)).toString();
const file2Contents = fs.readFileSync(path.join(diff.path2, diff.name2)).toString();
expect(file1Contents).toEqual(file2Contents);
});

expect(res.same).toBe(true);
rimraf(exampleOutput, done);
try {
expect(err).toBeFalsy();
expect(stats.compilation.errors).toEqual([]);

const dircompare = require('dir-compare');
const res = dircompare.compareSync(fixturePath, exampleOutput, { compareSize: true });

res.diffSet.filter(diff => diff.state === 'distinct').forEach(diff => {
const file1Contents = fs.readFileSync(path.join(diff.path1, diff.name1)).toString();
const file2Contents = fs.readFileSync(path.join(diff.path2, diff.name2)).toString();
expect(file1Contents).toEqual(file2Contents);
});

expect(res.same).toBe(true);
rimraf(exampleOutput, done);
} catch (e) {
done(e);
}
});
});
}
Expand Down

0 comments on commit 24c37a5

Please sign in to comment.