diff --git a/tests/__snapshots__/module.test.ts.snap b/tests/__snapshots__/module.test.ts.snap index f7f94db..b92d027 100644 --- a/tests/__snapshots__/module.test.ts.snap +++ b/tests/__snapshots__/module.test.ts.snap @@ -1,33 +1,25 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`createServer 1`] = ` -{ - "exitCode": 0, - "stderr": "", - "stdout": " ► Running task export... - ► ✓ Task export exited with code 0 - ► Running task print... -exported FOO=bar - ► ✓ Task print exited with code 0 -", -} +"{ + \\"exitCode\\": 0, + \\"stdout\\": \\" ► Running task export...\\\\n ► ✓ Task export exited with code 0\\\\n ► Running task print...\\\\nexported FOO=bar\\\\r\\\\n ► ✓ Task print exited with code 0\\\\n\\", + \\"stderr\\": \\"\\" +}" `; exports[`run 1`] = ` -{ - "exitCode": 0, - "stderr": "", - "stdout": "Hello World -", -} +"{ + \\"exitCode\\": 0, + \\"stdout\\": \\"Hello World\\\\r\\\\n\\", + \\"stderr\\": \\"\\" +}" `; exports[`run 2`] = ` -{ - "exitCode": 1, - "stderr": "", - "stdout": "exit -failed to run command \\"fail\\": exit code: 1 -", -} +"{ + \\"exitCode\\": 1, + \\"stdout\\": \\"failed to run command \\\\\\"fail\\\\\\": exit code: 1\\\\n\\", + \\"stderr\\": \\"\\" +}" `; diff --git a/tests/module.test.ts b/tests/module.test.ts index f57b8b3..b6e30b7 100644 --- a/tests/module.test.ts +++ b/tests/module.test.ts @@ -7,6 +7,11 @@ import { run, createServer } from '../src/index.js' const __dirname = url.fileURLToPath(new URL('.', import.meta.url)) +// reliable snapshots x-platform and node versions +function toJsonSnapshot(obj: any) { + return JSON.stringify(obj, null, 1) +} + beforeAll(async () => { await fs.rm( path.resolve(__dirname, '..', '.bin'), @@ -15,15 +20,15 @@ beforeAll(async () => { }) test('run', async () => { - expect(await run(['helloWorld'])) + expect(toJsonSnapshot(await run(['helloWorld']))) .toMatchSnapshot() - expect(await run(['fail'], { ignoreReturnCode: true })) + expect(toJsonSnapshot(await run(['fail'], { ignoreReturnCode: true }))) .toMatchSnapshot() }) test('createServer', async () => { const server = await createServer() - expect(await run(['export', 'print'], { server })) + expect(toJsonSnapshot(await run(['export', 'print'], { server }))) .toMatchSnapshot() server.kill() })