Skip to content

Commit

Permalink
fix: ensure re-run of spec occurs when supportFile has change
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiller1990 committed Dec 5, 2022
1 parent db41507 commit e1d766c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 9 deletions.
10 changes: 5 additions & 5 deletions .circleci/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mainBuildFilters: &mainBuildFilters
only:
- develop
- /^release\/\d+\.\d+\.\d+$/
- 'ryanm/fix/v8-improvements'
- 'lmiller/issue-24874-css-updates'

# usually we don't build Mac app - it takes a long time
# but sometimes we want to really confirm we are doing the right thing
Expand All @@ -37,15 +37,15 @@ macWorkflowFilters: &darwin-workflow-filters
when:
or:
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ 'ryanm/fix/v8-improvements', << pipeline.git.branch >> ]
- equal: [ 'lmiller/issue-24874-css-updates', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
linuxArm64WorkflowFilters: &linux-arm64-workflow-filters
when:
or:
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ 'ryanm/fix/v8-improvements', << pipeline.git.branch >> ]
- equal: [ 'lmiller/issue-24874-css-updates', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
Expand All @@ -63,7 +63,7 @@ windowsWorkflowFilters: &windows-workflow-filters
when:
or:
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ 'ryanm/fix/v8-improvements', << pipeline.git.branch >> ]
- equal: [ 'lmiller/issue-24874-css-updates', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
Expand Down Expand Up @@ -129,7 +129,7 @@ commands:
- run:
name: Check current branch to persist artifacts
command: |
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "ryanm/fix/v8-improvements" ]]; then
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "lmiller/issue-24874-css-updates" ]]; then
echo "Not uploading artifacts or posting install comment for this branch."
circleci-agent step halt
fi
Expand Down
42 changes: 42 additions & 0 deletions npm/vite-dev-server/cypress/e2e/vite-dev-server.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,48 @@ describe('Config options', () => {
expect(verifyFile).to.eq('OK')
})
})

it('supports HMR for css imported to supportFile', () => {
cy.scaffoldProject('vite3.0.2-react')
cy.openProject('vite3.0.2-react', ['--config-file', 'cypress-vite.config.ts'])
cy.startAppServer('component')

cy.visitApp()
cy.contains('App.cy.jsx').click()
cy.waitForSpecToFinish()
cy.get('.passed > .num').should('contain', 2)

cy.withCtx(async (ctx) => {
await ctx.actions.file.writeFileInProject(
'cypress/support/backgroundColor.css',
`.sample-bg {
background: blue;
}`,
)

await ctx.actions.file.writeFileInProject(
'src/App.cy.jsx', `
import React from 'react'
import { App } from './App'
it('renders blue background', () => {
cy.mount(<App />)
cy.get('h1').should('have.css', 'background-color', 'rgb(0, 0, 255)')
})`,
)

await ctx.actions.file.writeFileInProject(
'src/App.jsx', `
import React from 'react'
export const App = () => {
return <h1 className='sample-bg'>Updated Hello World</h1>
}`,
)
})

// Now we only have one spec that asserts the background is blue, not red (which means a re-run was triggered.)
cy.get('.passed > .num').should('contain', 1)
})
})

describe('sourcemaps', () => {
Expand Down
8 changes: 5 additions & 3 deletions npm/vite-dev-server/src/plugins/cypress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,15 @@ export const Cypress = (
// as soon as we find one of the specs, we trigger the re-run of tests
for (const mod of moduleImporters.values()) {
debug('handleHotUpdate - mod.file', mod.file)
// always re-run on supportFile changed
if (mod.file === supportFilePath) {
debug('handleHotUpdate - support compile success')
devServerEvents.emit('dev-server:compile:success')
server.ws.send({
type: 'full-reload',
})

// if we update support we know we have to re-run it all
// no need to check further
return []
return
}

if (mod.file && specsPathsSet.has(mod.file)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3541,5 +3541,5 @@
"./tooling/v8-snapshot/cache/dev-linux/snapshot-entry.js"
],
"deferredHashFile": "yarn.lock",
"deferredHash": "844da7908a41692a3b04716c88e2f0cdad85ece6f94f6ab89fbd1ffe5c332fd2"
"deferredHash": "e48c44c628ea6b968dae0697bf1fb37e18bc69913676524512ca41dcff3a985a"
}

4 comments on commit e1d766c

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e1d766c Dec 5, 2022

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 arm64 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/12.0.0/linux-arm64/lmiller/issue-24874-css-updates-e1d766ce9fa8ce9d3803f634f91e5104d3e17140/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e1d766c Dec 5, 2022

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/12.0.0/linux-x64/lmiller/issue-24874-css-updates-e1d766ce9fa8ce9d3803f634f91e5104d3e17140/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e1d766c Dec 5, 2022

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 arm64 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/12.0.0/darwin-arm64/lmiller/issue-24874-css-updates-e1d766ce9fa8ce9d3803f634f91e5104d3e17140/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e1d766c Dec 5, 2022

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/12.0.0/darwin-x64/lmiller/issue-24874-css-updates-e1d766ce9fa8ce9d3803f634f91e5104d3e17140/cypress.tgz

Please sign in to comment.