Closed kgilles closed 7 months ago
On Windows:
$ npm run test:unit
> sublinks-frontend@0.1.0 test:unit
> jest
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In C:\Users\Evan\code\src\sublinks\sublinks-frontend
646 files checked across 2 projects. Run with `--verbose` for more details.
Pattern: - 0 matches
MINGW64 ~/code/src/sublinks/sublinks-frontend (unit-tests)
$ ./node_modules/jest/bin/jest.js --verbose
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In C:\Users\Evan\code\src\sublinks\sublinks-frontend
323 files checked.
testMatch: /**/*.test.[jt]s?(x) - 0 matches
testPathIgnorePatterns: \\node_modules\\ - 323 matches
testRegex: - 0 matches
In C:\Users\Evan\code\src\sublinks\sublinks-frontend
323 files checked.
testMatch: /**/*.server.test.[jt]s?(x) - 0 matches
testPathIgnorePatterns: \\node_modules\\ - 323 matches
testRegex: - 0 matches
Pattern: - 0 matches
MINGW64 ~/code/src/sublinks/sublinks-frontend (unit-tests)
$ ls src/utils/__tests__/
api-client.server.test.ts communities.test.ts logger.test.ts
api-client.test.ts links.test.ts
I'll test in linux when I get back home. If you don't have a windows box to test with, I can take a crack at finding the bug. Not sure if windows as a dev environment is supported or not by the project though. If not, and linux looks good, this lgtm.
I'll test in linux when I get back home. If you don't have a windows box to test with, I can take a crack at finding the bug. Not sure if windows as a dev environment is supported or not by the project though. If not, and linux looks good, this lgtm.
Good call! I do have a windows machine, but recently got a Mac which is what I used for this PR.
I tried it with my PC now and saw the same thing. Turns out Windows needs a dot to tell it it's a relative path. Let me know if it works for you now.
$ npm run test:unit
> sublinks-frontend@0.1.0 test:unit
> jest
PASS client src/utils/__tests__/communities.test.ts
PASS client src/utils/__tests__/logger.test.ts
PASS client src/utils/__tests__/links.test.ts
PASS client src/utils/__tests__/api-client.server.test.ts
PASS client src/utils/__tests__/api-client.test.ts
PASS server src/utils/__tests__/api-client.server.test.ts
PASS client src/hooks/__tests__/use-scroll-height.test.tsx
Test Suites: 7 passed, 7 total
Tests: 46 passed, 46 total
Snapshots: 0 total
Time: 5.211 s, estimated 6 s
Ran all test suites in 2 projects.
LGTM
Merging without updated approval as the only change since has been to docs
This adds Jest and its friends to the repo. Allowing us to write and run unit tests on both client- and server-side. I tried Node's own test runner at first, but it's not yet up to par with Jest.
This PR is not meant to add tests to cover everything. It's a smaller version to show how we could configure things. For now covering our utils and one PoC hook test.
It also creates a new GitHub workflow which, when approved, will be a requirement for future PRs.
And finally I moved some files around and renamed some others as we had hooks living under
utils/
rather thanhooks/
When this is approved I'll update the README and Contribution guidelines.