Skip to content

Commit

Permalink
Merge pull request #5 from aleclarson/test/prefixing
Browse files Browse the repository at this point in the history
test: ensure prefixing handles line segments
  • Loading branch information
Kikobeats authored Aug 26, 2024
2 parents 51dc49a + 2963bed commit 409bf29
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,26 @@ test('run multiple tasks', async t => {
t.is(resolved[1].subprocess.stdout, 'bar')
t.true(durations[1].duration >= 1000)
})

test('prefixing handles line segments', t => {
const { execSync } = require('child_process')

let program = `
process.stdout.write('hello ', () => {
process.stdout.write('world\\n', () => {
process.stdout.write('nice to meet you')
})
})
`

program = program.replace(/\\/g, '\\\\')
program = `node -e "${program}"`
program = program.replace(/"/g, '\\"')

const stdout = execSync(`./bin/index.js "${program}" --names "foo"`, {
encoding: 'utf-8',
stdio: 'pipe'
})

t.snapshot(stdout)
})
20 changes: 20 additions & 0 deletions test/snapshots/index.js.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Snapshot report for `test/index.js`

The actual snapshot is saved in `index.js.snap`.

Generated by [AVA](https://avajs.dev).

## prefixing handles line segments

> Snapshot 1
`foo started pid=79072␊
foo hello foo world␊
foo nice to meet youfoo cmd='node -e "␊
process.stdout.write('hello ', () => {␊
process.stdout.write('world\\n', () => {␊
process.stdout.write('nice to meet you')␊
})␊
})␊
"' exitCode=0 signalCode=null duration=0s␊
`
Binary file added test/snapshots/index.js.snap
Binary file not shown.

0 comments on commit 409bf29

Please sign in to comment.