Skip to content

Commit

Permalink
chore: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind committed Nov 4, 2024
1 parent f859218 commit 4287f65
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const mockFn = jest.fn();

let lastCompilation;

class MyPlugin {
apply(compiler) {
compiler.hooks.compilation.tap("Plugin", compilation => {
if (lastCompilation) {
return;
}
lastCompilation = compilation;
});
}
}

/** @type {import('../..').TCompilerCaseConfig} */
module.exports = {
description: "throw error when access outdated compilation",
options(context) {
return {
context: context.getSource(),
entry: "./d",
plugins: [new MyPlugin()]
};
},
async build(_, compiler) {
await new Promise(resolve => {
compiler.run(() => {
compiler.run(() => {
resolve();
});
});
});
},
async check() {
expect(() => lastCompilation.modules).toThrow(/Unable to access compilation/);
}
};

0 comments on commit 4287f65

Please sign in to comment.