I've got my Yarn package.json
set up like this, where I create a global variable called localPath
.
{
jest: {
globals: {
localPath: Users/alex/Git/mytodolist
}
}
}
Then, in one of my spec tests, I run
console.log(localPath)
but get this error.
ReferenceError: localPath is not defined
5 |
> 6 | console.log(localPath)
Does anyone know how to call the global variable you set up? I can only find articles on creating the variable, but not on how to call it.
Source: https://jestjs.io/docs/en/configuration#globals-object
Edit: Thanks to @slideshowp2 for the correct answer below. Turns out I didn't need to use a global variable in the end, as you can dynamically grab the execution path at run time. However, this will certainly be useful in the future.
beforeAll(async () => {
await page.goto('file:///'+process.cwd()+'/index.html')
})