Skip to content

Commit 254eb47

Browse files
dmtrKovalenkolmiller1990elevatebartBarthélémy Ledoux
authored
fix(component-testing): Fix webpack-dev-server deps validation crash (#15708)
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com> Co-authored-by: ElevateBart <ledouxb@gmail.com> Co-authored-by: Barthélémy Ledoux <bart@cypress.io>
1 parent cd66b05 commit 254eb47

File tree

15 files changed

+816
-2766
lines changed

15 files changed

+816
-2766
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export const MIN_SUPPORTED_VERSION = {
22
'react-scripts': '^=3.x || ^=4.x',
3-
next: '^=9.x',
3+
next: '^=9.x || ^=10.x',
44
}

npm/create-cypress-tests/src/main.ts

+17-11
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,22 @@ async function askForComponentTesting () {
5151
return shouldSetupComponentTesting
5252
}
5353

54-
function printCypressCommandsHelper ({ useYarn }: { useYarn: boolean }) {
55-
const displayedCommand = useYarn ? 'yarn' : 'npx'
56-
57-
console.log('Inside this directory, you can run several commands:')
58-
console.log()
59-
console.log(chalk.cyan(` ${displayedCommand} cypress open`))
60-
console.log(' Opens cypress local development app.')
61-
console.log()
62-
console.log(chalk.cyan(` ${displayedCommand} cypress run`))
63-
console.log(' Runs tests in headless mode.')
54+
function printCypressCommandsHelper (options: { shouldSetupComponentTesting: boolean, useYarn: boolean }) {
55+
const printCommand = (command: string, description: string) => {
56+
const displayedRunner = options.useYarn ? 'yarn' : 'npx'
57+
58+
console.log()
59+
console.log(chalk.cyan(` ${displayedRunner} ${command}`))
60+
console.log(` ${description}`)
61+
}
62+
63+
printCommand('cypress open', 'Opens cypress local development app.')
64+
printCommand('cypress run', 'Runs tests in headless mode.')
65+
66+
if (options.shouldSetupComponentTesting) {
67+
printCommand('cypress open-ct', 'Opens cypress component-testing web app.')
68+
printCommand('cypress run', 'Runs component testing in headless mode.')
69+
}
6470
}
6571

6672
export async function main ({ useNpm, ignoreTs, setupComponentTesting, ignoreExamples }: MainArgv) {
@@ -92,7 +98,7 @@ export async function main ({ useNpm, ignoreTs, setupComponentTesting, ignoreExa
9298
}
9399

94100
console.log(`\n👍 Success! Cypress is installed and ready to run tests.`)
95-
printCypressCommandsHelper({ useYarn })
101+
printCypressCommandsHelper({ useYarn, shouldSetupComponentTesting })
96102

97103
console.log(`\nHappy testing with ${chalk.green('cypress.io')} 🌲\n`)
98104
}

npm/react/examples/nextjs/cypress/components/Router.spec.jsx

+6-28
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
/// <reference types="cypress" />
33
import * as React from 'react'
44
import RouterPage from '../../pages/router'
5-
import { createRouter } from 'next/router'
65
import { RouterContext } from 'next/dist/next-server/lib/router-context'
76
import { mount } from '@cypress/react'
87

@@ -22,6 +21,9 @@ describe('Component with router usage', () => {
2221
reload: cy.spy(),
2322
back: cy.spy(),
2423
prefetch: cy.spy(),
24+
isReady: true,
25+
isPreview: false,
26+
isLocaleDomain: false,
2527
beforePopState: cy.spy(),
2628
}
2729

@@ -34,33 +36,6 @@ describe('Component with router usage', () => {
3436
cy.contains('Next.js route /testPath')
3537
})
3638

37-
it('renders the component that uses next.js with parsed query', () => {
38-
// alternatively you can use next's internal `createRouter` function to create a real instance of NextRouter
39-
const router = createRouter(
40-
'/testPath',
41-
{ param1: 'param1' },
42-
'/asTestPath',
43-
{
44-
subscription: cy.spy(),
45-
initialProps: {},
46-
App: cy.spy(),
47-
Component: cy.spy(),
48-
pageLoader: cy.spy(),
49-
initialStyleSheets: [],
50-
wrapApp: cy.spy(),
51-
isFallback: false,
52-
},
53-
)
54-
55-
mount(
56-
<RouterContext.Provider value={router}>
57-
<RouterPage />
58-
</RouterContext.Provider>,
59-
)
60-
61-
cy.contains('My query: {"param1":"param1"}')
62-
})
63-
6439
it('pushes the new route', () => {
6540
const router = {
6641
pathname: '/router',
@@ -76,6 +51,9 @@ describe('Component with router usage', () => {
7651
reload: cy.spy(),
7752
back: cy.spy(),
7853
prefetch: cy.spy(),
54+
isReady: true,
55+
isPreview: false,
56+
isLocaleDomain: false,
7957
beforePopState: cy.spy(),
8058
}
8159

npm/react/examples/nextjs/package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
"devDependencies": {
1616
"@cypress/react": "file:../../dist",
1717
"@mdx-js/loader": "^1.6.16",
18-
"@next/mdx": "10.0.7",
18+
"@next/mdx": "10.1.2",
1919
"@zeit/next-sass": "^1.0.1",
2020
"check-code-coverage": "1.9.2",
2121
"cypress-circleci-reporter": "0.2.0",
22-
"next": "10.0.7",
23-
"webpack": "^4.44.2"
22+
"next": "10.1.2"
2423
},
2524
"license": "MIT"
2625
}

0 commit comments

Comments
 (0)