DEV Community

Eakam
Eakam

Posted on

Starchart: Week 7

For week 7, I continued with my work on the DNS Record creation page. This basically involved resolving all the review comments, and trying to get tests working. However, I ran into another sign in problem in the Playwright test environment:

Metadata not found

I did not want to resolve this specific issue in the same PR as the one creating the page so I decided to create a separate issue for it.

While working on the DNS Record creation page, I rebased my branch with the main branch as it had gotten out of date. After this, I found that I could no longer run the app, and got this error:

'SECRETS_OVERRIDE' is not recognized as an internal or external
command, operable program or batch file.
Enter fullscreen mode Exit fullscreen mode

I saw that the dev script had been modified to override an ENV variable:

"dev": "SECRETS_OVERRIDE=1 run-p dev:*"
Enter fullscreen mode Exit fullscreen mode

However, this syntax is not supported on Windows. So, I created a PR to use cross_env so it would also work on windows.

After addressing all the comments on my original PR (to create the new page UI), I helped Genne23v resolve CI failure on this PR. New code had been added that would check for an ENV variable value and crash if the environment was production and no value was specified. However, this should not have affected the end to end tests as the environment there was set to testing:

"start:e2e": "cross-env NODE_ENV=testing node --require
dotenv/config ./build/server.js",
Enter fullscreen mode Exit fullscreen mode

This script starts the app when end to end tests are run. However, after some investigation and through this discussion, I found that there were two problems with this approach:

  • testing is not a valid value for NODE_ENV. Providing testing will result in NODE_ENV being set to production

  • During the build process, all calls to process.env.NODE_ENV in the code are replaced with the actual value for NODE_ENV. Thus, something like console.log(process.env.NODE_ENV) would become console.log("production"). This was done by the following script. Here, no value for NODE_ENV is given, and therefore production is assumed by default.

 "pretest:e2e:run": "cross-env SECRETS_OVERRIDE=1 run-s build"
Enter fullscreen mode Exit fullscreen mode

Moving the override to this script and changing the value to test resulted in the CI passing again:

"pretest:e2e:run": "cross-env NODE_ENV=test SECRETS_OVERRIDE=1
run-s build"
Enter fullscreen mode Exit fullscreen mode

More information about this process can be found in this discussion.

Top comments (0)