Skip to content

Commit

Permalink
Ensure PATH env matches CI locally (#45376)
Browse files Browse the repository at this point in the history
Since the tests are run with `pnpm test` locally this adds the repo's
`node_modules/.bin` to the PATH env variable although in CI `node
run-tests.js` is used which doesn't augment PATH like this so this
strips these from the env when running isolated tests to match behavior.

x-ref: [slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1674913457101449)
  • Loading branch information
ijjk authored Jan 29, 2023
1 parent 1df9300 commit 13b32ba
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/lib/next-modes/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ export class NextInstance {

constructor(opts: NextInstanceOpts) {
Object.assign(this, opts)

this.env = {
...this.env,
// remove node_modules/.bin repo path from env
// to match CI $PATH value and isolate further
PATH: process.env.PATH.split(path.delimiter)
.filter((part) => {
return !part.includes(path.join('node_modules', '.bin'))
})
.join(path.delimiter),
}
}

protected async writeInitialFiles() {
Expand Down

0 comments on commit 13b32ba

Please sign in to comment.