From a3704856217693e0a86324fc8f50e95325a0dd97 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 17 Oct 2022 13:03:20 +0200 Subject: [PATCH] use absolute paths --- standalone-cli/tests/test.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/standalone-cli/tests/test.js b/standalone-cli/tests/test.js index 3d4ba24d1748..eacad793328b 100644 --- a/standalone-cli/tests/test.js +++ b/standalone-cli/tests/test.js @@ -1,3 +1,4 @@ +const path = require('path') const { execSync } = require('child_process') const os = require('os') const fs = require('fs-extra') @@ -34,11 +35,16 @@ it('supports first-party plugins', () => { it('supports postcss config files', async () => { // We have to run this test outside of any place with node_modules for it to properly test this situation - let result = await inIsolatedContext(() => { + let result = await inIsolatedContext((base) => { // Emulate the user adding their own postcss plugins execSync(`npm install postcss-will-change`) - return exec('--content tests/fixtures/basic.html --postcss tests/fixtures/postcss.config.js') + return exec( + `--content ${path.resolve(base, 'tests/fixtures/basic.html')} --postcss ${path.resolve( + base, + 'tests/fixtures/postcss.config.js' + )}` + ) }) expect(result).toContain('.uppercase') @@ -51,7 +57,7 @@ it('supports postcss config files', async () => { /** * @template T * @param {() => T} fn - * @returns {T} + * @returns {Promise} */ async function inIsolatedContext(fn) { // Create a new directory entirely outside of the package for the test @@ -73,7 +79,7 @@ async function inIsolatedContext(fn) { process.chdir(dest) try { - return await fn() + return await fn(dest) } finally { // Change back to the original working directory process.chdir(__dirname)