Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix tests that fail on windows #21055

Merged
merged 33 commits into from Apr 19, 2022
Merged

Conversation

lmiller1990
Copy link
Contributor

@lmiller1990 lmiller1990 commented Apr 12, 2022

User facing changelog

Fixes some flaky tests.

Additional details

  • fixes some runner mocha event tests w/ a slightly longer timeout
  • fixes an issue where git info wasn't working correctly due to / vs \ on different OSs
  • fixes race condition where could not connect to CDP when launching with cypress --browser chrome which primarily manifested on windows

How has the user experience changed?

Tests pass on windows.

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • Has a PR for user-facing changes been opened in cypress-documentation?
  • Have API changes been updated in the type definitions?
  • Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 12, 2022

Thanks for taking the time to open a PR!


// windows returns a leading carriage return, remove it
const [, ...stdout] = split
let output: string[] = []
Copy link
Contributor Author

Choose a reason for hiding this comment

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

More reliable way to pass shell command output.

@lmiller1990 lmiller1990 marked this pull request as ready for review April 12, 2022 23:03
const split = result.stdout
.split('\r\n') // windows uses CRLF for carriage returns
.filter((str) => !str.includes('git log')) // windows stdout contains [cmd,output]. So we remove the code containing the executed command, `git log`
const stdout = normalize(result.stdout).split('\r\n') // windows uses CRLF for carriage returns
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the problem, / vs \.

Def need to standardize how we handle this internally. At least w/ this PR we have more coverage and confidence across all OSes, for when we do try to standardize this (if we need to make changes, maybe we don't).

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah... maybe a guides/ would be good. Maybe a guide all about platform differences, not just paths?

In general, I think it should work like this:

  1. We should always use the native path if it is being displayed to the user. Unless it's displayed in a place where it may be shared cross-platform in a programmatic way (like require(path), import path, or in the URL bar)
  2. We should always use the native path internally unless the library does not support it (like in globby, where \ acts as an escape character.

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Guides + trusted windows tests would be a good place to start. Shared utils/libs to handle the translation when necessary could help too.

@cypress
Copy link

cypress bot commented Apr 12, 2022



Test summary

4343 0 48 0Flakiness 1


Run details

Project cypress
Status Passed
Commit a2a5e24
Started Apr 19, 2022 5:38 AM
Ended Apr 19, 2022 5:51 AM
Duration 13:34 💡
OS Linux Debian - 10.10
Browser Electron 94

View run in Cypress Dashboard ➡️


Flakiness

cypress/e2e/commands/net_stubbing.cy.ts Flakiness
1 network stubbing > intercepting request > can delay and throttle a StaticResponse

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

packages/data-context/src/sources/GitDataSource.ts Outdated Show resolved Hide resolved
packages/data-context/src/sources/GitDataSource.ts Outdated Show resolved Hide resolved
const split = result.stdout
.split('\r\n') // windows uses CRLF for carriage returns
.filter((str) => !str.includes('git log')) // windows stdout contains [cmd,output]. So we remove the code containing the executed command, `git log`
const stdout = normalize(result.stdout).split('\r\n') // windows uses CRLF for carriage returns
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah... maybe a guides/ would be good. Maybe a guide all about platform differences, not just paths?

In general, I think it should work like this:

  1. We should always use the native path if it is being displayed to the user. Unless it's displayed in a place where it may be shared cross-platform in a programmatic way (like require(path), import path, or in the URL bar)
  2. We should always use the native path internally unless the library does not support it (like in globby, where \ acts as an escape character.

What do you think?

packages/data-context/src/sources/GitDataSource.ts Outdated Show resolved Hide resolved
// should update via GraphQL subscription, now the status is modified.
cy.get('[data-cy-row="dom-container.spec.js"]')
.contains('Modified')
.get('[data-cy="git-status-modified"]')
Copy link
Contributor

Choose a reason for hiding this comment

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

Good call on the additional coverage 👍

@lmiller1990 lmiller1990 requested a review from a team as a code owner April 13, 2022 23:12
circle.yml Outdated
@@ -1189,6 +1189,8 @@ jobs:
parallelism: 1
steps:
- restore_cached_workspace
- run: mkdir -p ~/.ssh
Copy link
Collaborator

Choose a reason for hiding this comment

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

I really wish I knew why this was necessary (still looking). The problem seems to only be happening on my PRs

circle.yml Outdated Show resolved Hide resolved
@@ -0,0 +1,85 @@
# Remaining Platform Agnostic
Copy link
Contributor

Choose a reason for hiding this comment

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

"Writing Cross-Platform JavaScript" might be a clearer title, or something along those lines? Thanks for adding this, now we have something to point to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated!

@@ -67,7 +67,7 @@
:id="getIdIfDirectory(row)"
:key="row.index"
:data-cy="row.data.isLeaf ? 'spec-list-file' : 'spec-list-directory'"
:data-cy-row="row.data.data?.relative"
:data-cy-row="row.data.data?.baseName"
Copy link
Contributor

Choose a reason for hiding this comment

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

Just wanted to note that using baseName here doesn't guarantee uniqueness like relative did. Doesn't seem like it impacts any current tests, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep - I think it's probably fine for now, actually updating the paths is a bit of scope creep, and changing the paths dynamically for the assertion seems like more technical debt. This seems like a reasonable trade-off.


// TODO: Move this into packages/error post merge: https://github.com/cypress-io/cypress/pull/20072
Copy link
Contributor

@tbiethman tbiethman Apr 14, 2022

Choose a reason for hiding this comment

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

Is this TODO worth persisting/doing?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This fix actually negates the rationale for the TODO (which is nice). This scenarios is now handled by this catch block:

https://github.com/cypress-io/cypress/pull/21055/files#diff-b5b66d85423fa714add2e866448d3411b0f1cdf2cb4b4a95aa80394fa3edd1b3R57

which properly displays the appropriate error.

@lmiller1990
Copy link
Contributor Author

I have responded to the comments

  • updated guide
  • updated guide name
  • added some comments to explain what code does

@lmiller1990 lmiller1990 merged commit 0a320d3 into 10.0-release Apr 19, 2022
@lmiller1990 lmiller1990 deleted the lmiller1990/windows-fails branch April 19, 2022 10:05
tgriesser added a commit that referenced this pull request Apr 20, 2022
…e-config

* 10.0-release:
  chore: Move component-index generation to scaffold-config package (#21090)
  fix: label text should be clickable to toggle snapshot highlight (#21122)
  feat: add next preset to webpack-dev-server-fresh (#21069)
  chore: add dev-servers as deps to server to be included in the binary (#21142)
  fix: do not highlight preExtension if selected option is renameFolder (#21121)
  fix(unify): Remove 'Reconfigure' dropdown from Testing Type chooser (#21063)
  feat(unify): launchpad header breadcrumbs and reusable tooltip component (#20648)
  test: add windows-test-kitchensink job (#20847)
  fix: aut centering and height calculation (#21019)
  chore: fix tests that fail on windows (#21055)
  fix: running a new test after already having run tests (#21087)
  fix: ct project setup framework keys for next and nuxt (#21116)
  fix: remove MountReturn from scaffolded ct support file (#21119)
  fix: do not scaffold fixtures if folder exist (#21078)
  fix: revert "fix: types for Cypress.Commands.add (#20376)" (#21104)
  chore: Update Chrome (stable) to 100.0.4896.127 and Chrome (beta) to 101.0.4951.34 (#21083)
  fix: types for Cypress.Commands.add (#20376) (#20377)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants