-
Notifications
You must be signed in to change notification settings - Fork 4
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
[DSDK-67] Setup unit test #4
[DSDK-67] Setup unit test #4
Conversation
b519c7a
to
dea3823
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, but could be cool to define an test with assert true in order to run it on CI and check that it's working normally.
ded522b
to
6e0586a
Compare
f306cc4
to
9f6315b
Compare
"@types/jest": "^29.5.11", | ||
"@types/node": "^20.10.6", | ||
"eslint": "^8.56.0", | ||
"jest": "^29.7.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to move jest dev dependency to `packages/config/jest/package.json``
Same for others dependencies (eslint, typescript)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving those depencies in the appropriates config packages doesn't work because turbo links the local folder instead of installing the dependencies of an internal package.
node_modules
βββ @ledgerhq
βΒ Β βββ eslint-config-dsdk -> ../../../config/eslint
βΒ Β βββ jest-config-dsdk -> ../../../config/jest
βΒ Β βββ tsconfig-dsdk -> ../../../config/typescript
I also tried to set the bin field of the config package pointing to a binary, like "bin": { "tsc": "./node_modules/.bin/tsc" }
in config/typescript/package.json
, the link works and the binary can be used in other packages but the first pnpm install
fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's sad, actually from official turbo basic example, eslint
and others dev binary dependencies are not defined in the root package.json
but on each apps/packages package.json
that need it.
I don't know which solution is the best π€
- Declare in the root
package.json
one time, but all packages will have it - Declare on each package, more strict but not more convenient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's a better solution to have an unique version in root package.json
.
Moreover those 3 packages, eslint
jest
& typescript
, are used by the sample app and every other external packages of the monorepo as binaries.
9f6315b
to
289a196
Compare
LGTM π |
289a196
to
be3574b
Compare
.github/workflows/pull_request.yml
Outdated
@@ -1,7 +1,7 @@ | |||
name: pull_request | |||
on: [pull_request] | |||
jobs: | |||
lint: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we keep the lint test? because at the same time lint
can be failing while test
is passing (unless I'm missing something)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lint task is still executed as defined in turbo.json
:
"test": {
"dependsOn": ["build", "lint"],
}
I changed it in this PR to verify the test job in CI, but in the git workflow proposed by @mbertin-ledger the test job is only executed once a branch is merged.
So I guess you're right it should be 2 different jobs
1518907
to
e1be8d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
@@ -3,7 +3,7 @@ | |||
"compilerOptions": { | |||
"target": "esnext", | |||
"lib": ["esnext", "dom"], | |||
"types": ["reflect-metadata"], | |||
"types": ["reflect-metadata", "jest", "node"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we create a different target only for the test files to have the jest annontations/types ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible but we would have to redefine the entire compilerOptions for the test files in that case and another extends section each module. Wouldn't it a bit overcomplex?
- name: Lint | ||
run: pnpm lint | ||
- name: Test | ||
run: pnpm test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as build
and lint
are dependencies of the test
script (described in your turbo.json
update), pnpm test
will in fact run pnpm build
pnpm lint
and pnpm test
so I think it's a bit redundant to run both in the CI.
However, maybe lint
should not be a dependency of test
? not sure how we want to handle our testing strategy (codechecks/unit/integration tests etc...)
right now this is just an observation but yeah, we need to think about it
@@ -13,6 +13,11 @@ | |||
"dependsOn": ["build"], | |||
"cache": false, | |||
"persistent": true | |||
}, | |||
"test": { | |||
"dependsOn": ["build", "lint"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
open question: should lint
be a dependency of the test suite ?
4767871
to
4c07846
Compare
5cab786
to
ea9f1d0
Compare
4c07846
to
889a91b
Compare
5ea0006
to
7d30cc5
Compare
5ce9a49
to
a1f5647
Compare
481012a
to
2c443d1
Compare
a1f5647
to
a41c52a
Compare
1d8aca8
into
feature/DSDK-80-setup-file-structure
π Description
Setup jest
β Context
β Checklist
Pull Requests must pass the CI and be code reviewed. Set as Draft if the PR is not ready.
npx changeset
was attached.pnpm test
scriptsπ§ Checklist for the PR Reviewers