Skip to content

Tests run in their local directory so .env file in the root won't be loaded #8

@andokai

Description

@andokai

Hi, first, thanks for creating this very helpful extension!

I'm using node:test to run tests for an API built with Fastify. I have some environment variables set in a .env file. Fastify uses Dotenv to read in environment variables from any .env file in the current working directory. So running node --test test/**/*.test.js works because that is run at the root. However, the same tests fail in this extension. I debugged the test and I could see that process.cwd() was telling me that the test was running inside the folder where the test was. To verify my assumption I copied the .env file into that folder and the test passed.

I'd rather not have to copy my .env file into every folder where I have a test or not set it in code, just for the sake of this extension, so could it be updated so that it runs tests from the project's root directory?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions