function createTestCase(changeTimeout, invalidate) {
		describe(`time between changes ${changeTimeout}ms${
			invalidate ? " with invalidate call" : ""
		}`, () => {
			const fixturePath = path.join(
				__dirname,
				"fixtures",
				`temp-${changeTimeout}`
			);
			const filePath = path.join(fixturePath, "file.js");
			const file2Path = path.join(fixturePath, "file2.js");
			const loaderPath = path.join(__dirname, "fixtures", "delay-loader.js");

			beforeAll(() => {
				try {
					fs.mkdirSync(fixturePath);
				} catch (_err) {
					// empty
				}
				fs.writeFileSync(filePath, "require('./file2')", "utf-8");
				fs.writeFileSync(file2Path, "original", "utf-8");
			});

			afterAll(done => {
				setTimeout(() => {
					try {
						fs.unlinkSync(filePath);
					} catch (_err) {
						// empty
					}
					try {
						fs.unlinkSync(file2Path);
					} catch (_err) {
						// empty
					}
					try {
						fs.rmdirSync(fixturePath);
					} catch (_err) {
						// empty
					}
					done();
				}, 100); // cool down a bit
			});

			it("should build the bundle correctly", done => {
				const compiler = webpack({
					mode: "development",
					entry: `${loaderPath}!${filePath}`,
					output: {
						path: "/directory",
						filename: "bundle.js"
					}
				});
				const memfs = (compiler.outputFileSystem = createFsFromVolume(
					new Volume()
				));
				let onChange;
				compiler.hooks.done.tap("WatchDetectionTest", () => {
					if (onChange) onChange();
				});

				let watcher;

				step1();

				/**
				 * @returns {void}
				 */
				function step1() {
					onChange = () => {
						if (
							memfs.readFileSync("/directory/bundle.js") &&
							memfs
								.readFileSync("/directory/bundle.js")
								.toString()
								.includes("original")
						)
							step2();
					};

					watcher = compiler.watch(
						{
							aggregateTimeout: 50
						},
						() => {}
					);
				}

				/**
				 * @returns {void}
				 */
				function step2() {
					onChange = () => {
						expect(compiler.modifiedFiles).not.toBe(undefined);
						expect(compiler.removedFiles).not.toBe(undefined);
					};

					fs.writeFile(
						filePath,
						"require('./file2'); again",
						"utf-8",
						handleError
					);

					setTimeout(step3, changeTimeout);
				}

				/**
				 * @returns {void}
				 */
				function step3() {
					if (invalidate) watcher.invalidate();
					fs.writeFile(file2Path, "wrong", "utf-8", handleError);

					setTimeout(step4, changeTimeout);
				}

				/**
				 * @returns {void}
				 */
				function step4() {
					onChange = () => {
						expect(compiler.modifiedFiles).not.toBe(undefined);
						expect(compiler.removedFiles).not.toBe(undefined);
						if (
							memfs
								.readFileSync("/directory/bundle.js")
								.toString()
								.includes("correct")
						)
							step5();
					};

					fs.writeFile(file2Path, "correct", "utf-8", handleError);
				}

				/**
				 * @returns {void}
				 */
				function step5() {
					onChange = null;

					watcher.close(() => {
						setTimeout(done, 500);
					});
				}

				/**
				 * @param {unknown} err err
				 */
				function handleError(err) {
					if (err) done(err);
				}
			});
		});
	}
@param {number} changeTimeout change timeout
@param {boolean=} invalidate need invalidate?