Skip to content

Commit

Permalink
fix(component-testing): Fix webpack-dev-server deps validation crash (#…
Browse files Browse the repository at this point in the history
…15708)

Co-authored-by: Lachlan Miller <[email protected]>
Co-authored-by: ElevateBart <[email protected]>
Co-authored-by: Barthélémy Ledoux <[email protected]>
  • Loading branch information
4 people authored Apr 2, 2021
1 parent cd66b05 commit 254eb47
Show file tree
Hide file tree
Showing 15 changed files with 816 additions and 2,766 deletions.
2 changes: 1 addition & 1 deletion npm/create-cypress-tests/src/component-testing/versions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const MIN_SUPPORTED_VERSION = {
'react-scripts': '^=3.x || ^=4.x',
next: '^=9.x',
next: '^=9.x || ^=10.x',
}
28 changes: 17 additions & 11 deletions npm/create-cypress-tests/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,22 @@ async function askForComponentTesting () {
return shouldSetupComponentTesting
}

function printCypressCommandsHelper ({ useYarn }: { useYarn: boolean }) {
const displayedCommand = useYarn ? 'yarn' : 'npx'

console.log('Inside this directory, you can run several commands:')
console.log()
console.log(chalk.cyan(` ${displayedCommand} cypress open`))
console.log(' Opens cypress local development app.')
console.log()
console.log(chalk.cyan(` ${displayedCommand} cypress run`))
console.log(' Runs tests in headless mode.')
function printCypressCommandsHelper (options: { shouldSetupComponentTesting: boolean, useYarn: boolean }) {
const printCommand = (command: string, description: string) => {
const displayedRunner = options.useYarn ? 'yarn' : 'npx'

console.log()
console.log(chalk.cyan(` ${displayedRunner} ${command}`))
console.log(` ${description}`)
}

printCommand('cypress open', 'Opens cypress local development app.')
printCommand('cypress run', 'Runs tests in headless mode.')

if (options.shouldSetupComponentTesting) {
printCommand('cypress open-ct', 'Opens cypress component-testing web app.')
printCommand('cypress run', 'Runs component testing in headless mode.')
}
}

export async function main ({ useNpm, ignoreTs, setupComponentTesting, ignoreExamples }: MainArgv) {
Expand Down Expand Up @@ -92,7 +98,7 @@ export async function main ({ useNpm, ignoreTs, setupComponentTesting, ignoreExa
}

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

console.log(`\nHappy testing with ${chalk.green('cypress.io')} 🌲\n`)
}
34 changes: 6 additions & 28 deletions npm/react/examples/nextjs/cypress/components/Router.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/// <reference types="cypress" />
import * as React from 'react'
import RouterPage from '../../pages/router'
import { createRouter } from 'next/router'
import { RouterContext } from 'next/dist/next-server/lib/router-context'
import { mount } from '@cypress/react'

Expand All @@ -22,6 +21,9 @@ describe('Component with router usage', () => {
reload: cy.spy(),
back: cy.spy(),
prefetch: cy.spy(),
isReady: true,
isPreview: false,
isLocaleDomain: false,
beforePopState: cy.spy(),
}

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

it('renders the component that uses next.js with parsed query', () => {
// alternatively you can use next's internal `createRouter` function to create a real instance of NextRouter
const router = createRouter(
'/testPath',
{ param1: 'param1' },
'/asTestPath',
{
subscription: cy.spy(),
initialProps: {},
App: cy.spy(),
Component: cy.spy(),
pageLoader: cy.spy(),
initialStyleSheets: [],
wrapApp: cy.spy(),
isFallback: false,
},
)

mount(
<RouterContext.Provider value={router}>
<RouterPage />
</RouterContext.Provider>,
)

cy.contains('My query: {"param1":"param1"}')
})

it('pushes the new route', () => {
const router = {
pathname: '/router',
Expand All @@ -76,6 +51,9 @@ describe('Component with router usage', () => {
reload: cy.spy(),
back: cy.spy(),
prefetch: cy.spy(),
isReady: true,
isPreview: false,
isLocaleDomain: false,
beforePopState: cy.spy(),
}

Expand Down
5 changes: 2 additions & 3 deletions npm/react/examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
"devDependencies": {
"@cypress/react": "file:../../dist",
"@mdx-js/loader": "^1.6.16",
"@next/mdx": "10.0.7",
"@next/mdx": "10.1.2",
"@zeit/next-sass": "^1.0.1",
"check-code-coverage": "1.9.2",
"cypress-circleci-reporter": "0.2.0",
"next": "10.0.7",
"webpack": "^4.44.2"
"next": "10.1.2"
},
"license": "MIT"
}
Loading

4 comments on commit 254eb47

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 254eb47 Apr 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/6.9.0/circle-develop-254eb47d91c75a9f56162e7493ab83e5be169935/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 254eb47 Apr 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/6.7.2/appveyor-develop-254eb47d91c75a9f56162e7493ab83e5be169935/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 254eb47 Apr 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/6.7.2/appveyor-develop-254eb47d91c75a9f56162e7493ab83e5be169935/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 254eb47 Apr 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/6.9.0/circle-develop-254eb47d91c75a9f56162e7493ab83e5be169935/cypress.tgz

Please sign in to comment.