Skip to content

Commit

Permalink
use absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Oct 17, 2022
1 parent 459dd22 commit a370485
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions 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')
Expand Down Expand Up @@ -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')
Expand All @@ -51,7 +57,7 @@ it('supports postcss config files', async () => {
/**
* @template T
* @param {() => T} fn
* @returns {T}
* @returns {Promise<T>}
*/
async function inIsolatedContext(fn) {
// Create a new directory entirely outside of the package for the test
Expand All @@ -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)
Expand Down

0 comments on commit a370485

Please sign in to comment.