Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Nov 9, 2023
1 parent 0e83db7 commit 99e842d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/specs/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default testSuite(async ({ describe }) => {
expect(tsxProcess.stderr).toMatch('Error: Missing required parameter "script path"');
});

test('watch files for changes', async ({ onTestFinish }) => {
test('watch files for changes', async ({ onTestFinish, onTestFail }) => {
let initialValue = Date.now();
const fixtureWatch = await createFixture({
'package.json': JSON.stringify({
Expand All @@ -43,6 +43,16 @@ export default testSuite(async ({ describe }) => {
cwd: fixtureWatch.path,
});

onTestFail(async () => {
if (tsxProcess.exitCode === null) {
console.log('Force killing hanging process\n\n');
tsxProcess.kill('SIGKILL');
console.log({
tsxProcess: await tsxProcess,
});
}
});

await processInteract(
tsxProcess.stdout!,
[
Expand All @@ -52,6 +62,10 @@ export default testSuite(async ({ describe }) => {
await fixtureWatch.writeFile('value.js', `export const value = ${initialValue};`);
return true;
}
console.warn({
expecting: `${initialValue}\n`,
received: data,
});
},
data => data.includes(`${initialValue}\n`),
],
Expand Down

0 comments on commit 99e842d

Please sign in to comment.