cypress: Component testing broken with NextJS 13.2.1

Current behavior

Component tests run fine on NextJS v13.1.1, but fail to compile on v13.2.1

The error received is unable to find module, where the module resolution relies on the tsconfig basePath setting in /cypress/tsconfig.json

Component test cypress config settings:

component: {
    devServer: {
      framework: 'next',
      bundler: 'webpack',
    },
}

Desired behavior

Component tests should compile and run using the tsconfig.json settings.

Possibly related NextJS change/update: https://github.com/vercel/next.js/pull/45455

Test code to reproduce

Run any component test that uses a custom cypress tsconfig with NextJS v13.2.1

Cypress Version

latest

Node version

v16.3

Operating System

MacOSX And Github Actions Linux

Debug Logs

No response

Other

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 31 (17 by maintainers)

Most upvoted comments

Hi friends, I fixed it! https://github.com/cypress-io/cypress/pull/26399 /cc @jamesopti @OleksiiKachan @yosi1314. You can test it out using a pre-release binary: https://github.com/cypress-io/cypress/commit/6a37c4ad0a427d2857964e0d6aab709f5dc281ac#comments

Next release is tomorrow, I’ll get some πŸ‘€ and βœ… so this can make it in 😎

βœ… Next 13.1.6 Cypress 12.7 ❌ Next 13.2.x Cypress 12.7 (when I started following this issue) (I forget what broke the first time – might have been the same issue?) ❌ Next. 13.2.x Cypress 12.8

Hope that helps.

When exactly can we expect this release?

@jamesopti did you try the pre-release? You can start using this right now: bf7771f#comments and then upgrade to the mainline release when it comes out.

Those pre-release binaries expire eventually, but it’s live for me right now.

Thanks for pointing out how easy it is to test with these!

I confirmed that this release passes all tests in our suite. Will wait for tomorrows deploy.

We will be looking into this in the next week or two! Sorry about the wait.

This doesn’t inspire a lot of confidence in the Component testing product πŸ˜•

I can confirm this is still broken for me too. the baseUrl setting is not being respected.

tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": {
      "publicImages/*": ["../public/images/*"]
    },
    "target": "es2015",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "sourceMap": true,
    "isolatedModules": true,
    "noImplicitReturns": true,
    "importHelpers": true,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": false,
    "allowSyntheticDefaultImports": true,
    "downlevelIteration": true,
    "strictBindCallApply": true,
    "jsx": "preserve",
    "incremental": true
  },
  "exclude": ["node_modules", "cypress", "./cypress.config.ts"],
  "include": [
    "next-env.d.ts",
    "fontawesome.d.ts",
    "**/*.ts",
    "**/*.tsx",
    "src/test/jest-setup.ts",
    "jest.config.ts"
  ]
}

@OleksiiKachan this will be included in release 12.8.0 which should be released today