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

Platform-specific grouping of tests for npm test #41

Closed
CMCDragonkai opened this issue May 21, 2022 · 6 comments
Closed

Platform-specific grouping of tests for npm test #41

CMCDragonkai opened this issue May 21, 2022 · 6 comments
Assignees
Labels
development Standard development

Comments

@CMCDragonkai
Copy link
Member

Specification

It would be ideal that upon running npm test or npm run test that it would execute all general tests, and then detect which platform we are on, and run platform-specific tests.

This would require the ability to "tag" certain tests to only be performed for platform specific group. Tagging would allow us to set the os.platform(), os.arch() and other arbitrary tags to be required.

Seems like there are 3 general solutions:

  1. Using jest-group-runner - this relies on comment annotations, and it seems to be file-specific
  2. Using separate directories and testing for platform requirements in a the shell - this is complicated by the fact that windows doesn't have the same shell
  3. Using conditional test functions - this requires creating some conditional utility functions, and this becomes specific a single test function, perhaps conditional describe can also be used

Additional context

Tasks

  1. ...
  2. ...
  3. ...
@CMCDragonkai CMCDragonkai added the development Standard development label May 21, 2022
@CMCDragonkai
Copy link
Member Author

Any sort of npm test load balancing will be affected by this too. So ideally nominal testing should be preferred, but due to the startup overhead of mac and windows, load balancing will be necessary for PK. It appears it is possible with a custom jest scheduler.

@CMCDragonkai
Copy link
Member Author

@emmacasolin relevant for the NAT testing in PK.

@CMCDragonkai
Copy link
Member Author

The most cross-platform way to do this is conditional test or describe. Where it checks the os.platform() before running the tests.

But I wonder what happens if a test file doesn't have any tests at all (because the condition was no for all tests in that file). It would be preferable that jest does not consider this an error.

@CMCDragonkai
Copy link
Member Author

When restarting on MatrixAI/Polykey#357, please investigate this @emmacasolin and spec out the tasks.

@CMCDragonkai
Copy link
Member Author

Here it is @emmacasolin I thought I wrote an issue already.

@CMCDragonkai
Copy link
Member Author

CMCDragonkai commented Jun 28, 2022

This was superseded by MatrixAI/Polykey#380, and it was in fact done using describeIf and testIf, that is conditional testing. However these 2 utilities are not in TS-demo-lib. TS-demo-lib doesn't actually need it atm.

We are not using any sort of group runner atm. If we do need to in the future, prefer using directories instead. It's just more stable and involves less infrastructure. Any selection of directories should be done through a scripts/somescript.js that is executed through an npm script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Standard development
Development

No branches or pull requests

2 participants