Skip to content

Commit

Permalink
fix: improve cross-platform support of new test
Browse files Browse the repository at this point in the history
- On Windows, mixed path separators are output by the watch utility.
  Normalize on / before searching for expected output.
- Remove wait on debounce and separate file writes based on stdout
  output.
  • Loading branch information
mdmower-csnw committed Aug 1, 2024
1 parent 8c2836f commit 213b094
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions tests/specs/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import type { NodeApis } from '../utils/tsx.js';
import { processInteract } from '../utils/process-interact.js';
import { createPackageJson } from '../fixtures.js';

// reRun debounce from src/watch/index.ts
const watchDebounce = 100;

export default testSuite(async ({ describe }, { tsx }: NodeApis) => {
describe('watch', async ({ test, describe, onFinish }) => {
const fixture = await createFixture({
Expand Down Expand Up @@ -338,7 +335,7 @@ export default testSuite(async ({ describe }, { tsx }: NodeApis) => {
const chunkString = data.toString();
if (chunkString.includes('content-a content-b')) {
await fixture.writeFile(fileA, 'update-a');
await setTimeout(watchDebounce + 10);
} else if (chunkString.includes('update-a content-b')) {
await fixture.writeFile(fileB, 'update-b');
} else if (chunkString.includes('update-a update-b')) {
await fixture.writeFile(entryFile, 'console.log("TERMINATE")');
Expand All @@ -348,7 +345,7 @@ export default testSuite(async ({ describe }, { tsx }: NodeApis) => {
});

const tsxProcessResolved = await tsxProcess;
const stdout = stripAnsi(tsxProcessResolved.stdout);
const stdout = stripAnsi(tsxProcessResolved.stdout).replaceAll(/\\+/, '/');
expect(stdout).toContain(`change in ./${fileA}`);
expect(stdout).toContain(`change in ./${fileB}`);
expect(stdout).toContain(`change in ./${entryFile}`);
Expand Down

0 comments on commit 213b094

Please sign in to comment.