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

issue: process is not defined #2

Closed
floifydaniel opened this issue Aug 10, 2022 · 3 comments
Closed

issue: process is not defined #2

floifydaniel opened this issue Aug 10, 2022 · 3 comments

Comments

@floifydaniel
Copy link

Thanks for making this package! I've followed the installation steps but getting a process is not defined error in my e2e test. Not sure what's going on but hoping maybe you know something I don't. Any ideas? I looked at your most recent commit to upgrade to Vite 3 but still stumped.

Environment

  • cypress@^10.3.1
  • vite@^3.0.0
  • cypress-vite@^1.0.2

Files

Main tsconfig.json at the root of my project

{
  "compilerOptions": {
    "baseUrl": ".",
    "target": "ESNext",
    "useDefineForClassFields": true,
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "allowJs": false,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "types": ["cypress"]
  },
  "exclude": ["**/node_modules", "**/dist"]
}

Which is extended in my main project's directory

{
  "extends": "../../tsconfig.json",
  "include": ["src/**/*", "cypress/**/*"],
  "references": [{ "path": "./tsconfig.node.json" }]
}

That also has tsconfig.node.json

{
  "compilerOptions": {
    "composite": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "allowSyntheticDefaultImports": true
  },
  "include": ["vite.config.ts"]
}

And vite.config.ts

import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [react()],
});

My cypress.config.ts looks like this

import { defineConfig } from "cypress";
import vitePreprocessor from "cypress-vite";

export default defineConfig({
  e2e: {
    baseUrl: "http://localhost:5173",
    setupNodeEvents(on, config) {
      on("file:preprocessor", vitePreprocessor());
    },
  },
});
@mammadataei
Copy link
Owner

This is because of vite 3 changes as described here vitejs/vite#8090. I think it must be fixed in #1, just didn't release it yet.

@mammadataei
Copy link
Owner

mammadataei commented Aug 11, 2022

v.1.1.0 released. I hope it solves this.

@floifydaniel
Copy link
Author

@mammadataei it seems to have fixed this. One thing that might helpful to add to the docs is it requires NODE_ENV to be set before it'll work otherwise it emits the error Invalid NODE_ENV. For example, my open command looks like this: NODE_ENV=development yarn cypress open. Thanks for your time addressing this, I'll close out the issue.

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

2 participants