cypress-io / netlify-plugin-cypress

Runs Cypress end-to-end tests after Netlify builds the site but before it is deployed
https://www.cypress.io/blog/2020/03/30/run-cypress-tests-on-netlify-using-a-single-line/
MIT License
89 stars 39 forks source link

Next.js i18n Cypress fails pre-build and post-build #233

Open jonathanwelton opened 3 years ago

jonathanwelton commented 3 years ago

Versions

Describe the bug Since we added next-i18next and configured it in the next.config.js our Cypress tests pre-build and post-build have failed.

If the plugin is configured to run post-deployment, all the Cypress tests pass as expected.

When we run the Cypress tests on pre-build we get the following error:

10:21:16 AM: Build ready to start
10:21:18 AM: build-image version: 0582042f4fc261adc7bd8333f34884959c577302
10:21:18 AM: build-image tag: v3.7.6
10:21:18 AM: buildbot version: cb3d235979bae64f617d34524cb2e8a9de68153f
10:21:18 AM: Fetching cached dependencies
10:21:18 AM: Starting to download cache of 463.2MB
10:21:22 AM: Finished downloading cache in 4.384944961s
10:21:22 AM: Starting to extract cache
10:21:35 AM: Finished extracting cache in 13.348959158s
10:21:35 AM: Finished fetching cache in 17.812834038s
10:21:35 AM: Starting to prepare the repo for build
10:21:36 AM: Preparing Git Reference refs/heads/main
10:21:36 AM: Parsing package.json dependencies
10:21:37 AM: Different build command detected, going to use the one specified in the Netlify configuration file: 'npm run build' versus 'npm build' in the Netlify UI
10:21:37 AM: Starting build script
10:21:37 AM: Installing dependencies
10:21:37 AM: Python version set to 2.7
10:21:38 AM: Started restoring cached node version
10:21:40 AM: Finished restoring cached node version
10:21:41 AM: v12.18.0 is already installed.
10:21:41 AM: Now using node v12.18.0 (npm v6.14.4)
10:21:41 AM: Started restoring cached build plugins
10:21:41 AM: Finished restoring cached build plugins
10:21:41 AM: Attempting ruby version 2.7.1, read from environment
10:21:42 AM: Using ruby version 2.7.1
10:21:43 AM: Using PHP version 5.6
10:21:43 AM: Started restoring cached node modules
10:21:43 AM: Finished restoring cached node modules
10:21:43 AM: Started restoring cached go cache
10:21:43 AM: Finished restoring cached go cache
10:21:43 AM: go version go1.14.4 linux/amd64
10:21:43 AM: go version go1.14.4 linux/amd64
10:21:43 AM: Installing missing commands
10:21:43 AM: Verify run directory
10:21:44 AM: ​
10:21:44 AM: ────────────────────────────────────────────────────────────────
10:21:44 AM:   Netlify Build                                                 
10:21:44 AM: ────────────────────────────────────────────────────────────────
10:21:44 AM: ​
10:21:44 AM: ❯ Version
10:21:44 AM:   @netlify/build 11.18.1
10:21:44 AM: ​
10:21:44 AM: ❯ Flags
10:21:44 AM:   deployId: 60acc18cc6fa660007ba6e0a
10:21:44 AM: ​
10:21:44 AM: ❯ Current directory
10:21:44 AM:   /opt/build/repo
10:21:44 AM: ​
10:21:44 AM: ❯ Config file
10:21:44 AM:   /opt/build/repo/netlify.toml
10:21:44 AM: ​
10:21:44 AM: ❯ Context
10:21:44 AM:   production
10:21:44 AM: ​
10:21:44 AM: ❯ Loading plugins
10:21:44 AM:    - netlify-plugin-cypress@2.2.0 from netlify.toml and package.json
10:21:44 AM:    - @netlify/plugin-nextjs@3.3.0 from netlify.toml and package.json
10:21:45 AM: ​
10:21:45 AM: ────────────────────────────────────────────────────────────────
10:21:45 AM:   1. onPreBuild command from netlify-plugin-cypress             
10:21:45 AM: ────────────────────────────────────────────────────────────────
10:21:45 AM: ​
10:21:45 AM: 2021-05-25T09:21:45.359Z netlify-plugin-cypress installing Cypress binary just in case
10:21:45 AM: Note: Overriding Cypress cache directory to: ./node_modules/CypressBinary
10:21:45 AM:       Previous installs of Cypress may not be found.
10:21:45 AM: Cypress 7.3.0 is installed in /opt/build/repo/node_modules/CypressBinary/7.3.0
10:21:45 AM: Skipping installation:
10:21:45 AM:   Pass the --force option if you'd like to reinstall anyway.
2021-05-25T09:21:45.950Z netlify-plugin-cypress verifying Cypress can run
10:21:46 AM: [09:21:46]  Verifying Cypress can run /opt/build/repo/node_modules/CypressBinary/7.3.0/Cypress [started]
10:21:47 AM: [09:21:47]  Verifying Cypress can run /opt/build/repo/node_modules/CypressBinary/7.3.0/Cypress [completed]
10:21:47 AM: 2021-05-25T09:21:47.871Z netlify-plugin-cypress Cypress info
10:21:49 AM: Displaying Cypress info...
10:21:49 AM: Detected no known browsers installed
10:21:49 AM: Proxy Settings: none detected
10:21:49 AM: Environment Variables:
10:21:49 AM: CYPRESS_CACHE_FOLDER: ./node_modules/CypressBinary
10:21:49 AM: CYPRESS_RECORD_KEY: <redacted>
10:21:49 AM: Application Data: /opt/buildhome/.config/cypress/cy/development
10:21:49 AM: Browser Profiles: /opt/buildhome/.config/cypress/cy/development/browsers
10:21:49 AM: Binary Caches: /opt/build/repo/node_modules/CypressBinary
10:21:49 AM: Cypress Version: 7.3.0
10:21:49 AM: System Platform: linux (Ubuntu - 16.04)
10:21:49 AM: System Memory: 31.6 GB free 9.55 GB
10:21:49 AM: 2021-05-25T09:21:49.441Z netlify-plugin-cypress preBuild inputs { enable: true, record: true, start: 'npm run dev', 'wait-on': 'http://localhost:3000', 'wait-on-timeout': '30', group: 'test', tag: 'development build' }
10:21:49 AM: 2021-05-25T09:21:49.445Z netlify-plugin-cypress detached the process and returning stop function
10:21:49 AM: waiting on "http://localhost:3000" with timeout of 30 seconds
10:21:49 AM: 2021-05-25T09:21:49.446Z netlify-plugin-cypress pinging "http://localhost:3000" for 30000 ms max
10:21:49 AM: 2021-05-25T09:21:49.446Z netlify-plugin-cypress total ping timeout 30000
10:21:49 AM: 2021-05-25T09:21:49.446Z netlify-plugin-cypress individual ping timeout 30000ms
10:21:49 AM: 2021-05-25T09:21:49.446Z netlify-plugin-cypress retries limit 1
10:21:49 AM: 2021-05-25T09:21:49.469Z netlify-plugin-cypress:verbose got error {"name":"RequestError","code":"ECONNREFUSED"}
10:21:49 AM: 2021-05-25T09:21:49.469Z netlify-plugin-cypress:verbose 23ms undefined undefined ECONNREFUSED attempt 1
10:21:49 AM: > netlify-i18n-cypress-test@0.1.0 dev /opt/build/repo
10:21:49 AM: > next dev
10:21:49 AM: ready - started server on 0.0.0.0:3000, url: http://localhost:3000
10:21:50 AM: info  - Using webpack 5. Reason: no custom webpack configuration in next.config.js https://nextjs.org/docs/messages/webpack5
10:21:57 AM: event - compiled successfully
10:21:57 AM: event - build page: /next/dist/pages/_error
10:21:57 AM: wait  - compiling...
10:21:59 AM: event - compiled successfully
10:21:59 AM: 2021-05-25T09:21:59.727Z netlify-plugin-cypress:verbose got error {"name":"HTTPError"}
10:21:59 AM: 2021-05-25T09:21:59.727Z netlify-plugin-cypress:verbose 10281ms undefined undefined undefined attempt 2
10:22:29 AM: 2021-05-25T09:22:29.748Z netlify-plugin-cypress:verbose got error {"name":"HTTPError"}
10:22:29 AM: 2021-05-25T09:22:29.748Z netlify-plugin-cypress:verbose 40302ms undefined undefined undefined attempt 3
10:22:29 AM: http://localhost:3000 timed out on retry 3 of 1
10:22:29 AM: 2021-05-25T09:22:29.749Z netlify-plugin-cypress pinging http://localhost:3000 for 30000 ms failed
10:22:29 AM: 2021-05-25T09:22:29.749Z netlify-plugin-cypress HTTPError: Response code 404 (Not Found)
10:22:29 AM:     at EventEmitter.<anonymous> (/opt/build/repo/node_modules/got/dist/source/as-promise.js:118:31)
10:22:29 AM:     at processTicksAndRejections (internal/process/task_queues.js:97:5)
10:22:29 AM: ​
10:22:29 AM: ────────────────────────────────────────────────────────────────
10:22:29 AM:   Plugin "netlify-plugin-cypress" failed                        
10:22:29 AM: ────────────────────────────────────────────────────────────────
10:22:29 AM: ​
10:22:29 AM:   Error message
10:22:29 AM:   HTTPError: Response code 404 (Not Found)
10:22:29 AM: ​
10:22:29 AM:   Plugin details
10:22:29 AM:   Package:        netlify-plugin-cypress
10:22:29 AM:   Version:        2.2.0
10:22:29 AM:   Repository:     git+https://github.com/cypress-io/netlify-plugin-cypress.git
10:22:29 AM:   npm link:       https://www.npmjs.com/package/netlify-plugin-cypress
10:22:29 AM:   Report issues:  https://github.com/cypress-io/netlify-plugin-cypress/issues
10:22:29 AM: ​
10:22:29 AM:   Error location
10:22:29 AM:   In "onPreBuild" event in "netlify-plugin-cypress" from netlify.toml and package.json
10:22:29 AM: ​
10:22:29 AM:   Resolved config
10:22:29 AM:   build:
10:22:29 AM:     command: npm run build
10:22:29 AM:     commandOrigin: config
10:22:29 AM:     environment:
10:22:29 AM:       - CYPRESS_RECORD_KEY
10:22:29 AM:       - DEBUG
10:22:29 AM:       - CYPRESS_CACHE_FOLDER
10:22:29 AM:       - TERM
10:22:29 AM:     publish: /opt/build/repo/out
10:22:29 AM:   functions:
10:22:29 AM:     '*': {}
10:22:29 AM:   plugins:
10:22:29 AM:     - inputs:
10:22:29 AM:         enable: false
10:22:29 AM:         record: true
10:22:29 AM:       origin: config
10:22:29 AM:       package: netlify-plugin-cypress
10:22:29 AM:     - inputs: {}
10:22:29 AM:       origin: config
10:22:29 AM:       package: '@netlify/plugin-nextjs'
10:22:30 AM: Caching artifacts
10:22:30 AM: Started saving node modules
10:22:30 AM: Finished saving node modules
10:22:30 AM: Started saving build plugins
10:22:30 AM: Finished saving build plugins
10:22:30 AM: Started saving pip cache
10:22:30 AM: Finished saving pip cache
10:22:30 AM: Started saving emacs cask dependencies
10:22:30 AM: Finished saving emacs cask dependencies
10:22:30 AM: Started saving maven dependencies
10:22:30 AM: Finished saving maven dependencies
10:22:30 AM: Started saving boot dependencies
10:22:30 AM: Finished saving boot dependencies
10:22:30 AM: Started saving rust rustup cache
10:22:30 AM: Finished saving rust rustup cache
10:22:30 AM: Started saving go dependencies
10:22:30 AM: Finished saving go dependencies
10:22:30 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:22:30 AM: Creating deploy upload records
10:22:30 AM: Failing build: Failed to build site
10:22:30 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
10:22:30 AM: Finished processing build request in 1m12.780831277s

When we run the Cypress tests on post-build we get the following error:

10:23:17 AM: Build ready to start
10:23:19 AM: build-image version: 0582042f4fc261adc7bd8333f34884959c577302
10:23:19 AM: build-image tag: v3.7.6
10:23:19 AM: buildbot version: cb3d235979bae64f617d34524cb2e8a9de68153f
10:23:19 AM: Fetching cached dependencies
10:23:19 AM: Starting to download cache of 463.2MB
10:23:22 AM: Finished downloading cache in 3.523354811s
10:23:22 AM: Starting to extract cache
10:23:37 AM: Finished extracting cache in 14.412349242s
10:23:37 AM: Finished fetching cache in 18.049443785s
10:23:37 AM: Starting to prepare the repo for build
10:23:37 AM: Preparing Git Reference refs/heads/main
10:23:38 AM: Parsing package.json dependencies
10:23:39 AM: Different build command detected, going to use the one specified in the Netlify configuration file: 'npm run build' versus 'npm build' in the Netlify UI
10:23:39 AM: Starting build script
10:23:39 AM: Installing dependencies
10:23:39 AM: Python version set to 2.7
10:23:40 AM: Started restoring cached node version
10:23:42 AM: Finished restoring cached node version
10:23:42 AM: v12.18.0 is already installed.
10:23:43 AM: Now using node v12.18.0 (npm v6.14.4)
10:23:43 AM: Started restoring cached build plugins
10:23:43 AM: Finished restoring cached build plugins
10:23:43 AM: Attempting ruby version 2.7.1, read from environment
10:23:44 AM: Using ruby version 2.7.1
10:23:45 AM: Using PHP version 5.6
10:23:45 AM: Started restoring cached node modules
10:23:45 AM: Finished restoring cached node modules
10:23:45 AM: Started restoring cached go cache
10:23:45 AM: Finished restoring cached go cache
10:23:45 AM: go version go1.14.4 linux/amd64
10:23:45 AM: go version go1.14.4 linux/amd64
10:23:45 AM: Installing missing commands
10:23:45 AM: Verify run directory
10:23:47 AM: ​
10:23:47 AM: ────────────────────────────────────────────────────────────────
10:23:47 AM:   Netlify Build                                                 
10:23:47 AM: ────────────────────────────────────────────────────────────────
10:23:47 AM: ​
10:23:47 AM: ❯ Version
10:23:47 AM:   @netlify/build 11.18.1
10:23:47 AM: ​
10:23:47 AM: ❯ Flags
10:23:47 AM:   deployId: 60acc2050082460009187eeb
10:23:47 AM: ​
10:23:47 AM: ❯ Current directory
10:23:47 AM:   /opt/build/repo
10:23:47 AM: ​
10:23:47 AM: ❯ Config file
10:23:47 AM:   /opt/build/repo/netlify.toml
10:23:47 AM: ​
10:23:47 AM: ❯ Context
10:23:47 AM:   production
10:23:47 AM: ​
10:23:47 AM: ❯ Loading plugins
10:23:47 AM:    - netlify-plugin-cypress@2.2.0 from netlify.toml and package.json
10:23:47 AM:    - @netlify/plugin-nextjs@3.3.0 from netlify.toml and package.json
10:23:47 AM: ​
10:23:47 AM: ────────────────────────────────────────────────────────────────
10:23:47 AM:   1. onPreBuild command from netlify-plugin-cypress             
10:23:47 AM: ────────────────────────────────────────────────────────────────
10:23:47 AM: ​
10:23:47 AM: 2021-05-25T09:23:47.931Z netlify-plugin-cypress installing Cypress binary just in case
10:23:48 AM: Note: Overriding Cypress cache directory to: ./node_modules/CypressBinary
10:23:48 AM:       Previous installs of Cypress may not be found.
10:23:48 AM: Cypress 7.3.0 is installed in /opt/build/repo/node_modules/CypressBinary/7.3.0
10:23:48 AM: Skipping installation:
10:23:48 AM:   Pass the --force option if you'd like to reinstall anyway.
2021-05-25T09:23:48.642Z netlify-plugin-cypress verifying Cypress can run
10:23:49 AM: [09:23:49]  Verifying Cypress can run /opt/build/repo/node_modules/CypressBinary/7.3.0/Cypress [started]
10:23:50 AM: [09:23:50]  Verifying Cypress can run /opt/build/repo/node_modules/CypressBinary/7.3.0/Cypress [completed]
10:23:50 AM: 2021-05-25T09:23:50.659Z netlify-plugin-cypress Cypress info
10:23:52 AM: Displaying Cypress info...
10:23:52 AM: Detected no known browsers installed
10:23:52 AM: Proxy Settings: none detected
10:23:52 AM: Environment Variables:
10:23:52 AM: CYPRESS_CACHE_FOLDER: ./node_modules/CypressBinary
10:23:52 AM: CYPRESS_RECORD_KEY: <redacted>
10:23:52 AM: Application Data: /opt/buildhome/.config/cypress/cy/development
10:23:52 AM: Browser Profiles: /opt/buildhome/.config/cypress/cy/development/browsers
10:23:52 AM: Binary Caches: /opt/build/repo/node_modules/CypressBinary
10:23:52 AM: Cypress Version: 7.3.0
10:23:52 AM: System Platform: linux (Ubuntu - 16.04)
10:23:52 AM: System Memory: 31.6 GB free 11.6 GB
10:23:52 AM: 2021-05-25T09:23:52.572Z netlify-plugin-cypress preBuild inputs { enable: false, record: true, start: 'npm run dev', 'wait-on': 'http://localhost:3000', 'wait-on-timeout': '30', group: 'test', tag: 'development build' }
10:23:52 AM: 2021-05-25T09:23:52.572Z netlify-plugin-cypress Skipping preBuild tests
10:23:52 AM: ​
10:23:52 AM: (netlify-plugin-cypress onPreBuild completed in 4.6s)
10:23:52 AM: ​
10:23:52 AM: ────────────────────────────────────────────────────────────────
10:23:52 AM:   2. onPreBuild command from @netlify/plugin-nextjs             
10:23:52 AM: ────────────────────────────────────────────────────────────────
10:23:52 AM: ​
10:23:52 AM: info  - Using webpack 5. Reason: no custom webpack configuration in next.config.js https://nextjs.org/docs/messages/webpack5
10:23:53 AM: Next.js cache restored.
10:23:53 AM: ​
10:23:53 AM: (@netlify/plugin-nextjs onPreBuild completed in 844ms)
10:23:53 AM: ​
10:23:53 AM: ────────────────────────────────────────────────────────────────
10:23:53 AM:   3. build.command from netlify.toml                            
10:23:53 AM: ────────────────────────────────────────────────────────────────
10:23:53 AM: ​
10:23:53 AM: $ npm run build
10:23:53 AM: > netlify-i18n-cypress-test@0.1.0 build /opt/build/repo
10:23:53 AM: > next build
10:23:54 AM: info  - Using webpack 5. Reason: no custom webpack configuration in next.config.js https://nextjs.org/docs/messages/webpack5
10:23:54 AM: info  - Checking validity of types...
10:23:57 AM: info  - Creating an optimized production build...
10:23:59 AM: (node:1748) [DEP_WEBPACK_CHUNK_HAS_ENTRY_MODULE] DeprecationWarning: Chunk.hasEntryModule: Use new ChunkGraph API
10:23:59 AM: warn  - Compiled with warnings
10:23:59 AM: ./node_modules/next/dist/next-server/server/load-components.js
10:23:59 AM: Critical dependency: the request of a dependency is an expression
10:23:59 AM: ./node_modules/next/dist/next-server/server/load-components.js
10:23:59 AM: Critical dependency: the request of a dependency is an expression
10:23:59 AM: ./node_modules/next/dist/next-server/server/load-components.js
10:23:59 AM: Critical dependency: the request of a dependency is an expression
10:23:59 AM: ./node_modules/next/dist/next-server/server/require.js
10:23:59 AM: Critical dependency: the request of a dependency is an expression
10:23:59 AM: ./node_modules/next/dist/next-server/server/require.js
10:23:59 AM: Critical dependency: the request of a dependency is an expression
10:23:59 AM: ./node_modules/next/dist/next-server/server/require.js
10:23:59 AM: Critical dependency: the request of a dependency is an expression
10:23:59 AM: info  - Collecting page data...
10:24:00 AM: info  - Generating static pages (0/7)
10:24:01 AM: info  - Generating static pages (1/7)
10:24:01 AM: info  - Generating static pages (3/7)
10:24:01 AM: info  - Generating static pages (5/7)
10:24:01 AM: info  - Generating static pages (7/7)
10:24:01 AM: info  - Finalizing page optimization...
10:24:01 AM: Page                             Size     First Load JS
10:24:01 AM: ┌   /_app                        0 B            63.8 kB
10:24:01 AM: ├ ● /[slug]                      334 B          64.2 kB
10:24:01 AM: ├   └ /en-gb/SSG
10:24:01 AM: └ ○ /404                         3.06 kB        66.9 kB
10:24:01 AM: + First Load JS shared by all    63.8 kB
10:24:01 AM:   ├ chunks/framework.923004.js   42 kB
10:24:01 AM:   ├ chunks/main.767240.js        20.3 kB
10:24:01 AM:   ├ chunks/pages/_app.f51b67.js  543 B
10:24:01 AM:   └ chunks/webpack.2a5a41.js     952 B
10:24:01 AM: λ  (Lambda)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
10:24:01 AM: ○  (Static)  automatically rendered as static HTML (uses no initial props)
10:24:01 AM: ●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
10:24:01 AM:    (ISR)     incremental static regeneration (uses revalidate in getStaticProps)
10:24:01 AM: ​
10:24:01 AM: (build.command completed in 8.2s)
10:24:01 AM: ​
10:24:01 AM: ────────────────────────────────────────────────────────────────
10:24:01 AM:   4. onBuild command from @netlify/plugin-nextjs                
10:24:01 AM: ────────────────────────────────────────────────────────────────
10:24:01 AM: ​
10:24:01 AM: ** Running Next on Netlify package **
10:24:01 AM: 🚀 Next on Netlify 🚀
10:24:01 AM: 💼 Copying static NextJS assets to out
10:24:01 AM: 💫 Setting up API endpoints as Netlify Functions in netlify/functions
10:24:01 AM: 💫 Setting up pages with getInitialProps as Netlify Functions in netlify/functions
10:24:01 AM: 💫 Setting up pages with getServerSideProps as Netlify Functions in netlify/functions
10:24:01 AM: 🔥 Copying pre-rendered pages with getStaticProps and JSON data to out
10:24:01 AM: 💫 Setting up pages with getStaticProps and fallback: true as Netlify Functions in netlify/functions
10:24:01 AM: 💼 Copying WB5 dynamic import chunks to netlify/functions/next_slug/nextPage/chunks
10:24:01 AM: 💼 Copying WB5 dynamic import chunks to netlify/functions/next_slug/nextPage/chunks
10:24:01 AM: 💼 Copying WB5 dynamic import chunks to netlify/functions/next_slug/nextPage/chunks
10:24:01 AM: 💼 Copying WB5 dynamic import chunks to netlify/functions/next_slug/nextPage/chunks
10:24:01 AM: 💫 Setting up pages with getStaticProps and revalidation interval as Netlify Functions in netlify/functions
10:24:01 AM: 🔥 Copying pre-rendered pages without props to out
10:24:01 AM: 🔀 Setting up redirects
10:24:01 AM: 🔀 Setting up headers
10:24:01 AM: ✅ Success! All done!
10:24:01 AM: ​
10:24:01 AM: (@netlify/plugin-nextjs onBuild completed in 75ms)
10:24:01 AM: ​
10:24:01 AM: ────────────────────────────────────────────────────────────────
10:24:01 AM:   5. Functions bundling                                         
10:24:01 AM: ────────────────────────────────────────────────────────────────
10:24:01 AM: ​
10:24:01 AM: Packaging Functions from netlify/functions directory:
10:24:01 AM:  - next_image.js
10:24:01 AM:  - next_slug/next_slug.js
10:24:01 AM: ​
10:24:13 AM: ​
10:24:13 AM: (Functions bundling completed in 11.7s)
10:24:13 AM: ​
10:24:13 AM: ────────────────────────────────────────────────────────────────
10:24:13 AM:   6. onPostBuild command from netlify-plugin-cypress            
10:24:13 AM: ────────────────────────────────────────────────────────────────
10:24:13 AM: ​
10:24:13 AM: 2021-05-25T09:24:13.411Z netlify-plugin-cypress:verbose ===postBuild===
10:24:13 AM: 2021-05-25T09:24:13.411Z netlify-plugin-cypress cypress plugin postBuild inputs { enable: true, record: true, group: 'staging', tag: 'production build' }
10:24:13 AM: 2021-05-25T09:24:13.411Z netlify-plugin-cypress folder to publish is "out"
10:24:13 AM: 2021-05-25T09:24:13.412Z netlify-plugin-cypress serving local folder { directory: 'out', port: 8080, spa: undefined } from working directory /opt/build/repo
10:24:13 AM: 2021-05-25T09:24:13.576Z netlify-plugin-cypress local server listening on port 8080
10:24:13 AM: 2021-05-25T09:24:13.864Z netlify-plugin-cypress local Chromium revisions [ '848005' ]
10:24:13 AM: 2021-05-25T09:24:13.865Z netlify-plugin-cypress found Chromium { revision: '848005', executablePath: '/opt/build/repo/node_modules/puppeteer/.local-chromium/linux-848005/chrome-linux/chrome', folderPath: '/opt/build/repo/node_modules/puppeteer/.local-chromium/linux-848005', local: true, url: 'https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/848005/chrome-linux.zip', product: 'chrome' }
10:24:13 AM: 2021-05-25T09:24:13.865Z netlify-plugin-cypress run cypress params { baseUrl: 'http://localhost:8080', record: true, spec: undefined, group: 'staging', tag: 'production build', ciBuildId: '60acc2050082460009187ee9', browser: '/opt/build/repo/node_modules/puppeteer/.local-chromium/linux-848005/chrome-linux/chrome' }
10:24:19 AM: ====================================================================================================
10:24:19 AM:   (Run Starting)
10:24:19 AM:   ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
10:24:19 AM:   │ Cypress:    7.3.0                                                                              │
10:24:19 AM:   │ Browser:    Custom Chromium 90 (headless)                                                      │
10:24:19 AM:   │ Specs:      1 found (home.spec.ts)                                                             │
10:24:19 AM:   │ Params:     Tag: production build, Group: staging, Parallel: false                             │
10:24:19 AM:   │ Run URL:    https://dashboard.cypress.io/projects/rb57yh/runs/5                                │
10:24:19 AM:   └────────────────────────────────────────────────────────────────────────────────────────────────┘
10:24:19 AM: ────────────────────────────────────────────────────────────────────────────────────────────────────
10:24:19 AM:   Running:  home.spec.ts                                                                    (1 of 1)
10:24:19 AM:   Estimated: 8 seconds
10:24:23 AM: 
10:24:23 AM:   when visiting the Static Site Generated page
10:24:25 AM:     1) "before each" hook for "should diaply the correct locale"
10:24:25 AM:   when visiting the Server Side Rendered page
10:24:27 AM:     2) "before each" hook for "should diaply the correct locale"
10:24:27 AM:   0 passing (4s)
10:24:27 AM:   2 failing
10:24:27 AM:   1) when visiting the Static Site Generated page
10:24:27 AM:        "before each" hook for "should diaply the correct locale":
10:24:27 AM:      CypressError: `cy.visit()` failed trying to load:
10:24:27 AM: http://localhost:8080/ssg
10:24:27 AM: The response we received from your web server was:
10:24:27 AM:   > 404: Not Found
10:24:27 AM: This was considered a failure because the status code was not `2xx`.
10:24:27 AM: If you do not want status codes to cause failures pass the option: `failOnStatusCode: false`
10:24:27 AM: Because this error occurred during a `before each` hook we are skipping the remaining tests in the current suite: `when visiting the Static Si...`
10:24:27 AM:       at http://localhost:8080/__cypress/runner/cypress_runner.js:138860:25
10:24:27 AM:       at visitFailedByErr (http://localhost:8080/__cypress/runner/cypress_runner.js:138235:12)
10:24:27 AM:       at http://localhost:8080/__cypress/runner/cypress_runner.js:138840:13
10:24:27 AM:       at tryCatcher (http://localhost:8080/__cypress/runner/cypress_runner.js:10791:23)
10:24:27 AM:       at Promise._settlePromiseFromHandler (http://localhost:8080/__cypress/runner/cypress_runner.js:8726:31)
10:24:27 AM:       at Promise._settlePromise (http://localhost:8080/__cypress/runner/cypress_runner.js:8783:18)
10:24:27 AM:       at Promise._settlePromise0 (http://localhost:8080/__cypress/runner/cypress_runner.js:8828:10)
10:24:27 AM:       at Promise._settlePromises (http://localhost:8080/__cypress/runner/cypress_runner.js:8904:18)
10:24:27 AM:       at _drainQueueStep (http://localhost:8080/__cypress/runner/cypress_runner.js:5498:12)
10:24:27 AM:       at _drainQueue (http://localhost:8080/__cypress/runner/cypress_runner.js:5491:9)
10:24:27 AM:       at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:8080/__cypress/runner/cypress_runner.js:5507:5)
10:24:27 AM:       at Async.drainQueues (http://localhost:8080/__cypress/runner/cypress_runner.js:5377:14)
10:24:27 AM:   From Your Spec Code:
10:24:27 AM:       at Context.eval (http://localhost:8080/__cypress/tests?p=cypress/integration/home.spec.ts:98:12)
10:24:27 AM: 
10:24:27 AM:   2) when visiting the Server Side Rendered page
10:24:27 AM:        "before each" hook for "should diaply the correct locale":
10:24:27 AM:      CypressError: `cy.visit()` failed trying to load:
10:24:27 AM: http://localhost:8080/ssr
10:24:27 AM: The response we received from your web server was:
10:24:27 AM:   > 404: Not Found
10:24:27 AM: This was considered a failure because the status code was not `2xx`.
10:24:27 AM: If you do not want status codes to cause failures pass the option: `failOnStatusCode: false`
10:24:27 AM: Because this error occurred during a `before each` hook we are skipping the remaining tests in the current suite: `when visiting the Server Si...`
10:24:27 AM:       at http://localhost:8080/__cypress/runner/cypress_runner.js:138860:25
10:24:27 AM:       at visitFailedByErr (http://localhost:8080/__cypress/runner/cypress_runner.js:138235:12)
10:24:27 AM:       at http://localhost:8080/__cypress/runner/cypress_runner.js:138840:13
10:24:27 AM:       at tryCatcher (http://localhost:8080/__cypress/runner/cypress_runner.js:10791:23)
10:24:27 AM:       at Promise._settlePromiseFromHandler (http://localhost:8080/__cypress/runner/cypress_runner.js:8726:31)
10:24:27 AM:       at Promise._settlePromise (http://localhost:8080/__cypress/runner/cypress_runner.js:8783:18)
10:24:27 AM:       at Promise._settlePromise0 (http://localhost:8080/__cypress/runner/cypress_runner.js:8828:10)
10:24:27 AM:       at Promise._settlePromises (http://localhost:8080/__cypress/runner/cypress_runner.js:8904:18)
10:24:27 AM:       at _drainQueueStep (http://localhost:8080/__cypress/runner/cypress_runner.js:5498:12)
10:24:27 AM:       at _drainQueue (http://localhost:8080/__cypress/runner/cypress_runner.js:5491:9)
10:24:27 AM:       at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:8080/__cypress/runner/cypress_runner.js:5507:5)
10:24:27 AM:       at Async.drainQueues (http://localhost:8080/__cypress/runner/cypress_runner.js:5377:14)
10:24:27 AM:   From Your Spec Code:
10:24:27 AM:       at Context.eval (http://localhost:8080/__cypress/tests?p=cypress/integration/home.spec.ts:109:12)
10:24:27 AM: 
10:24:29 AM:   (Results)
10:24:29 AM:   ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
10:24:29 AM:   │ Tests:        4                                                                                │
10:24:29 AM:   │ Passing:      0                                                                                │
10:24:29 AM:   │ Failing:      2                                                                                │
10:24:29 AM:   │ Pending:      0                                                                                │
10:24:29 AM:   │ Skipped:      2                                                                                │
10:24:29 AM:   │ Screenshots:  2                                                                                │
10:24:29 AM:   │ Video:        true                                                                             │
10:24:29 AM:   │ Duration:     4 seconds                                                                        │
10:24:29 AM:   │ Estimated:    8 seconds                                                                        │
10:24:29 AM:   │ Spec Ran:     home.spec.ts                                                                     │
10:24:29 AM:   └────────────────────────────────────────────────────────────────────────────────────────────────┘
10:24:29 AM:   (Screenshots)
10:24:29 AM:   -  /opt/build/repo/cypress/screenshots/home.spec.ts/when visiting the Static Site G    (1920x1080)
10:24:29 AM:      enerated page -- should diaply the correct locale -- before each hook (failed).p
10:24:29 AM:      ng
10:24:29 AM:   -  /opt/build/repo/cypress/screenshots/home.spec.ts/when visiting the Server Side R    (1920x1080)
10:24:29 AM:      endered page -- should diaply the correct locale -- before each hook (failed).pn
10:24:29 AM:      g
10:24:29 AM:   (Video)
10:24:29 AM:   -  Started processing:  Compressing to 32 CRF
10:24:36 AM:   -  Finished processing: /opt/build/repo/cypress/videos/home.spec.ts.mp4                (6 seconds)
10:24:36 AM:   (Uploading Results)
10:24:36 AM:   - Done Uploading (1/3) /opt/build/repo/cypress/screenshots/home.spec.ts/when visiting the Server Side Rendered page -- should diaply the correct locale -- before each hook (failed).png
10:24:36 AM:   - Done Uploading (2/3) /opt/build/repo/cypress/videos/home.spec.ts.mp4
10:24:36 AM:   - Done Uploading (3/3) /opt/build/repo/cypress/screenshots/home.spec.ts/when visiting the Static Site Generated page -- should diaply the correct locale -- before each hook (failed).png
10:24:37 AM: ====================================================================================================
10:24:37 AM:   (Run Finished)
10:24:37 AM:        Spec                                              Tests  Passing  Failing  Pending  Skipped  
10:24:37 AM:   ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
10:24:37 AM:   │ ✖  home.spec.ts                             00:04        4        -        2        -        2 │
10:24:37 AM:   └────────────────────────────────────────────────────────────────────────────────────────────────┘
10:24:37 AM:     ✖  1 of 1 failed (100%)                     00:04        4        -        2        -        2  
10:24:37 AM: ───────────────────────────────────────────────────────────────────────────────────────────────────────
10:24:37 AM:   Recorded Run: https://dashboard.cypress.io/projects/rb57yh/runs/5
10:24:37 AM: 2021-05-25T09:24:37.558Z netlify-plugin-cypress closed local server on port 8080
10:24:37 AM: 2021-05-25T09:24:37.559Z netlify-plugin-cypress Cypress run results
10:24:37 AM: 2021-05-25T09:24:37.559Z netlify-plugin-cypress totalDuration: 4004
10:24:37 AM: 2021-05-25T09:24:37.559Z netlify-plugin-cypress totalSuites: 2
10:24:37 AM: 2021-05-25T09:24:37.559Z netlify-plugin-cypress totalTests: 4
10:24:37 AM: 2021-05-25T09:24:37.559Z netlify-plugin-cypress totalFailed: 2
10:24:37 AM: 2021-05-25T09:24:37.560Z netlify-plugin-cypress totalPassed: 0
10:24:37 AM: 2021-05-25T09:24:37.560Z netlify-plugin-cypress totalPending: 0
10:24:37 AM: 2021-05-25T09:24:37.560Z netlify-plugin-cypress totalSkipped: 2
10:24:37 AM: ​
10:24:37 AM: ────────────────────────────────────────────────────────────────
10:24:37 AM:   Plugin "netlify-plugin-cypress" failed                        
10:24:37 AM: ────────────────────────────────────────────────────────────────
10:24:37 AM: ​
10:24:37 AM:   Error message
10:24:37 AM:   Error: Failed Cypress tests
10:24:37 AM:   2 test(s) failed
10:24:37 AM: ​
10:24:37 AM:   Plugin details
10:24:37 AM:   Package:        netlify-plugin-cypress
10:24:37 AM:   Version:        2.2.0
10:24:37 AM:   Repository:     git+https://github.com/cypress-io/netlify-plugin-cypress.git
10:24:37 AM:   npm link:       https://www.npmjs.com/package/netlify-plugin-cypress
10:24:37 AM:   Report issues:  https://github.com/cypress-io/netlify-plugin-cypress/issues
10:24:37 AM: ​
10:24:37 AM:   Error location
10:24:37 AM:   In "onPostBuild" event in "netlify-plugin-cypress" from netlify.toml and package.json
10:24:37 AM:       at processCypressResults (/node_modules/netlify-plugin-cypress/src/utils.js:236:14)
10:24:37 AM:       at postBuild (/node_modules/netlify-plugin-cypress/src/onPostBuild.js:81:3)
10:24:37 AM:       at async module.exports (/node_modules/netlify-plugin-cypress/src/onPostBuild.js:123:3)
10:24:37 AM: ​
10:24:37 AM:   Resolved config
10:24:37 AM:   build:
10:24:37 AM:     command: npm run build
10:24:37 AM:     commandOrigin: config
10:24:37 AM:     environment:
10:24:37 AM:       - CYPRESS_RECORD_KEY
10:24:37 AM:       - DEBUG
10:24:37 AM:       - CYPRESS_CACHE_FOLDER
10:24:37 AM:       - TERM
10:24:37 AM:     publish: /opt/build/repo/out
10:24:37 AM:   functions:
10:24:37 AM:     '*': {}
10:24:37 AM:   plugins:
10:24:37 AM:     - inputs:
10:24:37 AM:         enable: false
10:24:37 AM:         record: true
10:24:37 AM:       origin: config
10:24:37 AM:       package: netlify-plugin-cypress
10:24:37 AM:     - inputs: {}
10:24:37 AM:       origin: config
10:24:37 AM:       package: '@netlify/plugin-nextjs'
10:24:38 AM: Caching artifacts
10:24:38 AM: Started saving node modules
10:24:38 AM: Finished saving node modules
10:24:38 AM: Started saving build plugins
10:24:38 AM: Finished saving build plugins
10:24:38 AM: Started saving pip cache
10:24:38 AM: Finished saving pip cache
10:24:38 AM: Started saving emacs cask dependencies
10:24:38 AM: Finished saving emacs cask dependencies
10:24:38 AM: Started saving maven dependencies
10:24:38 AM: Finished saving maven dependencies
10:24:38 AM: Started saving boot dependencies
10:24:38 AM: Finished saving boot dependencies
10:24:38 AM: Started saving rust rustup cache
10:24:38 AM: Finished saving rust rustup cache
10:24:38 AM: Started saving go dependencies
10:24:38 AM: Finished saving go dependencies
10:24:38 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:24:38 AM: Creating deploy upload records
10:24:38 AM: Failing build: Failed to build site
10:24:38 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
10:24:38 AM: Finished processing build request in 1m19.195244263s

Link to the repo https://github.com/jonathanwelton/netlify-i18n-cypress-test (currently configured to run the Cypress tests post-build)

boshdmg commented 3 years ago

Any news on this issue it's also affecting me.

It seems literally adding, the most basic boilerplate i18n config causes this.

module.exports = {
    i18n: { defaultLocale: 'en', locales: ['en'] },
    target: 'serverless',
}

Looking at the cypress videos the 'htaccess' is not set up correctly and cypress is seeing the folder structure, it seems the local folders are confusing the netlify plugin image

Maybe fullPublishFolder need to be set differently?

async function postBuild({
  utils,
  fullPublishFolder,
  record,
  spec,
  start,
  waitOn,
  waitOnTimeout,
  group,
  tag,
  spa,
  browser,
  configFile,
  errorCallback,
  summaryCallback,
})