diff --git a/package.json b/package.json index 0698ea0..c8ad795 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "yargs": "^18.0.0" }, "devDependencies": { - "ava": "^3.1.0", + "ava": "^8.0.0", "c8": "^12.0.0", "eslint": "^10.0.0", "eslint-config-problems": "10.0.1", diff --git a/test/stdin.js b/test/stdin.js index 5137694..7cc075e 100644 --- a/test/stdin.js +++ b/test/stdin.js @@ -7,22 +7,24 @@ import { exec } from 'node:child_process' import tmp from './helpers/tmp.js' import read from './helpers/read.js' -test.cb('reads from stdin', (t) => { +test('reads from stdin', (t) => { const output = tmp('output.css') - const cp = exec( - `node ${path.resolve('index.js')} -o ${output} --no-map`, - (error, stdout, stderr) => { - if (error) t.end(error, stderr) + return new Promise((resolve, reject) => { + const cp = exec( + `node ${path.resolve('index.js')} -o ${output} --no-map`, + (error) => { + if (error) return reject(error) - Promise.all([read(output), read('test/fixtures/a.css')]) - .then(([a, e]) => { - t.is(a, e) - t.end() - }) - .catch(t.end) - }, - ) + Promise.all([read(output), read('test/fixtures/a.css')]) + .then(([a, e]) => { + t.is(a, e) + resolve() + }) + .catch(reject) + }, + ) - createReadStream('test/fixtures/a.css').pipe(cp.stdin) + createReadStream('test/fixtures/a.css').pipe(cp.stdin) + }) }) diff --git a/test/stdout.js b/test/stdout.js index 6336cc7..0249c69 100644 --- a/test/stdout.js +++ b/test/stdout.js @@ -6,22 +6,27 @@ import { exec } from 'node:child_process' import read from './helpers/read.js' -test.cb('writes to stdout', (t) => { - const cp = exec( - `node ${path.resolve( - 'index.js', - )} --parser sugarss -u postcss-import --no-map`, - (error, stdout, stderr) => { - if (error) t.end(error, stderr) +test('writes to stdout', (t) => { + return new Promise((resolve, reject) => { + const cp = exec( + `node ${path.resolve( + 'index.js', + )} --parser sugarss -u postcss-import --no-map`, + (error, stdout) => { + if (error) return reject(error) - Promise.all([stdout.replace(/\r\n/g, '\n'), read('test/fixtures/s.css')]) - .then(([a, e]) => { - t.is(a, e) - t.end() - }) - .catch(t.end) - }, - ) + Promise.all([ + stdout.replace(/\r\n/g, '\n'), + read('test/fixtures/s.css'), + ]) + .then(([a, e]) => { + t.is(a, e) + resolve() + }) + .catch(reject) + }, + ) - createReadStream('./test/fixtures/a.sss').pipe(cp.stdin) + createReadStream('./test/fixtures/a.sss').pipe(cp.stdin) + }) })