Skip to content

Commit

Permalink
test dir creation
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Kowalleck <[email protected]>
  • Loading branch information
jkowalleck committed Dec 22, 2024
1 parent 3c5f237 commit f038049
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/integration/cli.from-setups.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.

const { spawnSync } = require('child_process')
const { dirname, join } = require('path')
const { writeFileSync, readFileSync } = require('fs')
const { writeFileSync, readFileSync, existsSync} = require('fs')

Check failure on line 22 in tests/integration/cli.from-setups.test.js

View workflow job for this annotation

GitHub Actions / test standards

A space is required before '}'

const { describe, expect, test } = require('@jest/globals')

Expand Down Expand Up @@ -58,6 +58,7 @@ describe('integration.cli.from-setups', () => {
function runTest (subject, project, format, additionalCliArgs = []) {
const expectedOutSnap = join(dummyResultsRoot, subject, `${project}.snap.${format}`)
const outFile = join(tmpRoot, subject, `${project}.${format}`)
const outDirExisted = existsSync(dirname(outFile))
// no need to create that outFile dir first - the tool is expected to do that for us
const res = spawnSync(
process.execPath,
Expand All @@ -84,6 +85,10 @@ describe('integration.cli.from-setups', () => {
throw err
}

const expectStdErr = expect(res.stderr);
(outDirExisted ? expectStdErr.not : expectStdErr).toContain(`creating directory ${dirname(outFile)}`)
expectStdErr.toMatch(new RegExp(`wrote \\d+ bytes to ${outFile}`))

const actualOutput = makeReproducible(format, readFileSync(outFile, 'utf8'))

if (UPDATE_SNAPSHOTS) {
Expand Down

0 comments on commit f038049

Please sign in to comment.