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

fix: fix some unit tests errors on win #30157

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from

Conversation

gweesin
Copy link
Contributor

@gweesin gweesin commented Sep 1, 2024

  • Closes N/A

Additional details

There are two primary differences in path and line break conventions across different operating systems:

1. Path separators: Paths are typically separated by a forward slash (/) on Unix-like systems (e.g., Linux, macOS) and a backslash () on Windows.

2. Line terminators: Line breaks are often represented by a carriage return and line feed sequence (\r\n) on Windows, while a single line feed character (\n) is used on Unix-like systems.

Steps to test

run yarn workspace @packages/data-context test

How has the user experience changed?

After identifying and correcting 25 errors in my previous work, I have successfully reduced the number to 14. I am currently diligently working to eliminate the remaining issues.

PR Tasks

@cypress-app-bot
Copy link
Collaborator

@gweesin
Copy link
Contributor Author

gweesin commented Sep 1, 2024

Still existing errors like this:

image
image
image

@gweesin
Copy link
Contributor Author

gweesin commented Sep 4, 2024

updating progress: yarn workspace @packages/data-context test only five errors running on windows now!

  370 passing (24s)
  1 pending
  5 failing

  1) FileDataSource
       #getFilesByGlob
         integration
           #getFilesByGlob
             does not replace working directory in glob pattern if it is not leading:
     Error: C:\Users\86159\AppData\Local\Temp\cy-projects\globby-test-bed\cypress\C:\Users\86159\AppData\Local\Temp\cy-projects\globby-test-bed contains invalid WIN32 path characters.
      at Object.mkdirs (node_modules\fs-extra\lib\mkdirs\mkdirs.js:18:22)
      at D:\opensource\cypress\node_modules\universalify\index.js:13:12
      at new Promise (<anonymous>)
      at Object.mkdirs (D:\opensource\cypress\node_modules\universalify\index.js:7:14)
      at Context.<anonymous> (test\unit\sources\FileDataSource.spec.ts:72:20)
      at processImmediate (node:internal/timers:476:21)

  2) FileDataSource
       #getFilesByGlob
         unit
           matches absolute patterns without including working dir in pattern:
     AssertionError: expected matchGlobs to have been called with arguments [ 'cypress/e2e/**.cy.js' ], {
  onlyFiles: true,
  absolute: true,
  ignore: [ '**/node_modules/**' ],
  cwd: '/my/project'
}
[ '/my/project/cypress/e2e/**.cy.js' ] [ 'cypress/e2e/**.cy.js' ]
{
  onlyFiles: true,
  absolute: true,
  ignore: [ '**/node_modules/**' ],
  cwd: '/my/project',
  ignore: [ '**/node_modules/**' ]
}
      at Context.<anonymous> (test\unit\sources\FileDataSource.spec.ts:254:45)

  3) FileDataSource
       #getFilesByGlob
         unit
           matches absolute patterns that include a copy of the working dir structure:
     AssertionError: expected matchGlobs to have been called with arguments [ 'cypress/my/project/e2e/**.cy.js' ], {
  onlyFiles: true,
  absolute: true,
  ignore: [ '**/node_modules/**' ],
  cwd: '/my/project'
}
[ '/my/project/cypress/my/project/e2e/**.cy.js' ] [ 'cypress/my/project/e2e/**.cy.js' ]
{
  onlyFiles: true,
  absolute: true,
  ignore: [ '**/node_modules/**' ],
  cwd: '/my/project',
  ignore: [ '**/node_modules/**' ]
}
      at Context.<anonymous> (test\unit\sources\FileDataSource.spec.ts:267:45)

  4) GitDataSource
       Git hashes
         detects change in hashes after a commit:
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (D:\opensource\cypress\packages\data-context\test\unit\sources\GitDataSource.spec.ts)
      at listOnTimeout (node:internal/timers:569:17)
      at processTimers (node:internal/timers:512:7)

  5) ProjectDataSource
       #defaultSpecFilename
         yields correct filename from specpattern if there are existing specs:
     AssertionError [ERR_ASSERTION]: Cannot get config file contents without a config manager
      at ProjectLifecycleManager.getConfigFileContents (src\data\ProjectLifecycleManager.ts:620:11)
      at ProjectDataSource.specPatternsByTestingType (src\sources\ProjectDataSource.ts:286:56)
      at ProjectDataSource.matchesSpecPattern (src\sources\ProjectDataSource.ts:519:82)
      at ProjectDataSource.defaultSpecFileName (src\sources\ProjectDataSource.ts:486:24)
      at async Context.<anonymous> (test\unit\sources\ProjectDataSource.spec.ts:818:35)



error Command failed with exit code 5.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@gweesin
Copy link
Contributor Author

gweesin commented Sep 4, 2024

Only two errors now, it seems caused by my env:

  367 passing (14s)
  1 pending
  2 failing

  1) GitDataSource
       "before each" hook for "gets correct status for files on win32":
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (D:\opensource\cypress\packages\data-context\test\unit\sources\GitDataSource.spec.ts)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

  2) ProjectDataSource
       #defaultSpecFilename
         yields correct filename from specpattern if there are existing specs:
     AssertionError [ERR_ASSERTION]: Cannot get config file contents without a config manager
      at ProjectLifecycleManager.getConfigFileContents (src\data\ProjectLifecycleManager.ts:620:11)
      at ProjectDataSource.specPatternsByTestingType (src\sources\ProjectDataSource.ts:286:56)
      at ProjectDataSource.matchesSpecPattern (src\sources\ProjectDataSource.ts:519:82)
      at ProjectDataSource.defaultSpecFileName (src\sources\ProjectDataSource.ts:486:24)
      at async Context.<anonymous> (test\unit\sources\ProjectDataSource.spec.ts:818:35)



error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@gweesin gweesin marked this pull request as ready for review September 4, 2024 08:37
@jennifer-shehane
Copy link
Member

@gweesin Could you add a changelog entry for this fix? There are instructions here: https://github.com/cypress-io/cypress/blob/develop/guides/writing-the-cypress-changelog.md

@jennifer-shehane
Copy link
Member

@gweesin There's still some errors in the tests, you can check CircleCI logs for full errors.

@AtofStryker AtofStryker self-requested a review September 23, 2024 15:24
@AtofStryker AtofStryker self-requested a review September 30, 2024 13:08
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.

4 participants