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

Custom matcher for paths on different OS #744

Open
5 tasks
BioPhoton opened this issue Jul 11, 2024 · 1 comment
Open
5 tasks

Custom matcher for paths on different OS #744

BioPhoton opened this issue Jul 11, 2024 · 1 comment
Labels
💡 good first issue good for newcomers 🆘 help wanted assistance is required 🔬 testing writing tests 🤓 UX UX improvement for CLI users

Comments

@BioPhoton
Copy link
Collaborator

BioPhoton commented Jul 11, 2024

User story

As a developer I want to have a good signal to noise ration and want to write my tests with as less boilerplate as possible.
Paths are environment specific and cause boilerplate to get properly tested.
Therefor I need a custom matcher for paths.

Existing helper:
os-agnostic-paths

Bad example:

expect(osAgnosticPath(process.cwd())).toEqual(
      expect.stringContaining(
        osAgnosticPath('project-root/other-folder'),
      ),
    );

Suggested matcher:

  • expect(myPath).toContainPath('...')
  • expect(myPath).toEndWithPath('...')

Good example:

// windows 'C:\Documnets\my-projects\project-root'
// linux '/home/my-projects/project-root'
expect(process.cwd()).toContainPath('project-root/other-folder');
expect(process.cwd()).toEndsWithPath('project-root/other-folder/src');

Acceptance criteria

I want to be able to use the custom matcher in the following libs:

  • vitest

Internal logic:

  • it handles path differences of all OS
    I want to be able to have different matcher present:
  • toContainPath('...')
  • toEndWithPath('...')
  • the existing code is using the helper, e.g. nx-plugin tests for persist.outputDir
@hanna-skryl
Copy link
Collaborator

@BioPhoton Hasn't #876 resolved this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 good first issue good for newcomers 🆘 help wanted assistance is required 🔬 testing writing tests 🤓 UX UX improvement for CLI users
Projects
None yet
Development

No branches or pull requests

2 participants