Skip to content

Commit

Permalink
fix: cleanup test flake (#21989)
Browse files Browse the repository at this point in the history
* fix: test flake in e2e tests

* fix flake in GitDataSource.spec.ts
  • Loading branch information
tgriesser committed Jun 1, 2022
1 parent 566a7b1 commit ae8d4b2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
32 changes: 17 additions & 15 deletions packages/data-context/test/unit/sources/GitDataSource.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ describe('GitDataSource', () => {
const onGitInfoChange = sinon.stub()
const onError = sinon.stub()

// create a file and modify a file to express all
// git states we are interested in (created, unmodified, modified)
const fooSpec = path.join(e2eFolder, 'foo.cy.js')
const aRecordSpec = path.join(e2eFolder, 'a_record.cy.js')
const xhrSpec = path.join(e2eFolder, 'xhr.cy.js')

gitInfo = new GitDataSource({
isRunMode: false,
projectRoot: projectPath,
Expand All @@ -55,28 +61,24 @@ describe('GitDataSource', () => {
onError,
})

// create a file and modify a file to express all
// git states we are interested in (created, unmodified, modified)
const fooSpec = path.join(e2eFolder, 'foo.cy.js')
const aRecordSpec = path.join(e2eFolder, 'a_record.cy.js')
const xhrSpec = path.join(e2eFolder, 'xhr.cy.js')

fs.createFileSync(fooSpec)
fs.writeFileSync(xhrSpec, 'it(\'modifies the file\', () => {})')

const dfd = pDefer()
gitInfo.setSpecs([fooSpec, aRecordSpec, xhrSpec])

onGitInfoChange.onSecondCall().callsFake(dfd.resolve)
let result: any[] = []

gitInfo.setSpecs([fooSpec, aRecordSpec, xhrSpec])
do {
result = await Promise.all([
gitInfo.gitInfoFor(fooSpec),
gitInfo.gitInfoFor(aRecordSpec),
gitInfo.gitInfoFor(xhrSpec),
])

await dfd.promise
await new Promise((resolve) => setTimeout(resolve, 100))
} while (result.some((r) => r == null))

const [created, unmodified, modified] = await Promise.all([
gitInfo.gitInfoFor(fooSpec),
gitInfo.gitInfoFor(aRecordSpec),
gitInfo.gitInfoFor(xhrSpec),
])
const [created, unmodified, modified] = result

expect(created.lastModifiedHumanReadable).to.match(/(a few|[0-9]) seconds? ago/)
expect(created.statusType).to.eql('created')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from 'cypress'
const { defineConfig } = require('cypress')

export default defineConfig({
module.exports = defineConfig({
component: {
supportFile: false,
devServer: {
Expand Down
2 changes: 1 addition & 1 deletion system-tests/projects/missing-webpack-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"webpack": "^5.0.0",
"webpack-dev-server": "4.9.0"
}
}
}

3 comments on commit ae8d4b2

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ae8d4b2 Jun 1, 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/10.0.0/linux-x64/develop-ae8d4b2b05ea0a5beec7bdc09e0214d04c3837e1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ae8d4b2 Jun 1, 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/10.0.0/darwin-x64/develop-ae8d4b2b05ea0a5beec7bdc09e0214d04c3837e1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ae8d4b2 Jun 1, 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 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/10.0.0/win32-x64/develop-ae8d4b2b05ea0a5beec7bdc09e0214d04c3837e1/cypress.tgz

Please sign in to comment.