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

Failed at "Cypress start:mocks" during CI workflow #7

Open
test-2287 opened this issue Sep 23, 2022 · 7 comments
Open

Failed at "Cypress start:mocks" during CI workflow #7

test-2287 opened this issue Sep 23, 2022 · 7 comments

Comments

@test-2287
Copy link

Hi, i followed the egghead course and the README file to deploy, but got throw new Error(prefix); at tiny-invariant

image

and i found npm run start:mocks have the same issue in my local dev env.

node version: v16.16.0
npm version: 8.11.0
platform: macOS bigSur

@kentcdodds
Copy link
Owner

Did you run the fly secrets set command before deploying?

@test-2287
Copy link
Author

@kentcdodds yes~ , i ran fly secrets set SESSION_SECRET=$(openssl rand -hex 32) --app blog-tutorial-c08c showed in the README and ran fly secrets set ADMIN_EMAIL=rachel@remix.run show in the course.

image

@kentcdodds
Copy link
Owner

Yeah, that's quite strange... I'm sorry, I don't know what it could be 😬

@test-2287
Copy link
Author

Yeah, that's quite strange... I'm sorry, I don't know what it could be 😬

i found cypress ran start:mocks failed cause it can't get the env variables, since the default NODE_ENV of remix serve run is production, it will always throw Error in tiny-invariant.js

var isProduction = process.env.NODE_ENV === 'production';
var prefix = 'Invariant failed';
function invariant(condition, message) {
    if (condition) {
        return;
    }
    if (isProduction) {
        throw new Error(prefix);
    }
    var provided = typeof message === 'function' ? message() : message;
    var value = provided ? prefix + ": " + provided : prefix;
    throw new Error(value);
}

module.exports = invariant;

i added the env as below in deploy.yml file and it works, i not sure if there is another better solution.
image

@kentcdodds
Copy link
Owner

Oh, did you update the .env.example? That's important because the github action will copy that file to .env before running the E2E tests.

@amite
Copy link

amite commented Oct 21, 2022

Oh, did you update the .env.example? That's important because the github action will copy that file to .env before running the E2E tests.

I am getting the same error. I tried updating the .env.example and it still crashes. I'll file a separate issue

@bbaki
Copy link

bbaki commented Mar 22, 2023

For anyone else trying to test the build locally, remix does not use .env file by default (link), also see this issue.

The solution is to use e.g. dotenv-cli like this: "start": "dotenv -e .env.production remix-serve build"

klevente added a commit to klevente/csirip that referenced this issue Apr 13, 2023
Required because Remix does not load them in production, but we need them for e2e:
- kentcdodds/onewheel-blog#7
- remix-run/remix#5341 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants