Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefinePlugin: Conflicting values for 'process.env.NODE_ENV' #672

Closed
matthew-white opened this issue Dec 5, 2022 · 1 comment
Closed
Labels
infrastructure Changes to core libraries or setup testing Integration tests, unit tests

Comments

@matthew-white
Copy link
Member

When I run npm run test, I see the following warning:

DefinePlugin
Conflicting values for 'process.env.NODE_ENV'

[
  {
    message: "DefinePlugin\nConflicting values for 'process.env.NODE_ENV'",
    details: `'"test"' !== '"development"'`,
    stack: '...'
  }
]

We set NODE_ENV to test based on the Vue CLI docs:

With NODE_ENV set to "test" for example, Vue CLI creates a webpack config that is intended to be used and optimized for unit tests.

When I add some debugging to karma.conf.js, I can see that the mode property of the webpack config object is 'development'. If I try to set it to 'test', I see an error:

04 12 2022 18:19:43.258:ERROR [karma-server]: Error during file loading or preprocessing
ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.mode should be one of these:
   "development" | "production" | "none"
   -> Enable production optimizations or development hints.

If I change NODE_ENV to production or development, I see that the resulting webpack config is different from when NODE_ENV is test.

There are differences between what we do in production vs. development vs. testing, in large part based on NODE_ENV. For example, we have more logging in development, while in testing, we expose access to local requestData resources.

I did a quick search of Vue CLI GitHub issues and didn't see anything related. I don't think we necessarily need to investigate this further, since tests seem to be working, and we'll be moving from Vue CLI as part of #671. But I wanted to file an issue with what I've learned so far.

@matthew-white matthew-white added testing Integration tests, unit tests infrastructure Changes to core libraries or setup labels Dec 5, 2022
@matthew-white
Copy link
Member Author

We're going to be switching from Karma to Vitest as part of #671, so I think we can close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Changes to core libraries or setup testing Integration tests, unit tests
Projects
None yet
Development

No branches or pull requests

1 participant