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 84c8b4f
Showing 1 changed file with 18 additions and 14 deletions.
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 84c8b4f

Please sign in to comment.