-
Notifications
You must be signed in to change notification settings - Fork 3
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
Tests - Package & Create Targets #73
base: main
Are you sure you want to change the base?
Tests - Package & Create Targets #73
Conversation
This pull request bring the targets to 100% code coverage :) ![]() |
* When you pass your own namedInputs (like you would in a project.json file) via the inferred tasks plugin, | ||
* the tasks pipeline ignores them and throws this error. | ||
* Some Nx plugins use the default namedInput, probably for that reason, | ||
* but I'm concerned that if developers change those inputs, it might lead to undesired behavior. |
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.
* When you pass your own namedInputs (like you would in a project.json file) via the inferred tasks plugin, | |
* the tasks pipeline ignores them and throws this error. | |
* Some Nx plugins use the default namedInput, probably for that reason, | |
* but I'm concerned that if developers change those inputs, it might lead to undesired behavior. | |
* When you pass your own `namedInputs` (like you would in a `project.json` file) via the inferred tasks plugin, | |
* the tasks pipeline ignores them and throws this error. | |
* Some Nx plugins use the default `namedInput`, probably for that reason, | |
* but I'm concerned that if developers change those inputs, it might lead to undesired behaviour. |
I assume this situation changed since the discussion in #62 made progress.
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 have pushed the changes you suggested. Should i leave it in code if the situation changed?
projects/nx-verdaccio/src/plugin/targets/create-targets.unit-test.ts
Outdated
Show resolved
Hide resolved
projects/nx-verdaccio/src/plugin/targets/create-targets.unit-test.ts
Outdated
Show resolved
Hide resolved
projects/nx-verdaccio/src/plugin/targets/create-targets.unit-test.ts
Outdated
Show resolved
Hide resolved
projects/nx-verdaccio/src/plugin/targets/create-targets.unit-test.ts
Outdated
Show resolved
Hide resolved
projects/nx-verdaccio/src/plugin/targets/create-targets.unit-test.ts
Outdated
Show resolved
Hide resolved
projects/nx-verdaccio/src/plugin/targets/package.targets.unit-test.ts
Outdated
Show resolved
Hide resolved
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.
Another nice testing PR!! <3
Very nice you even checked the coverage 💪! I found slight things we could adjust... have a look.
Any updates? |
I will push The changes today/tommorow |
…emove `correct structure` for consistency, add missing mockReturnFalse to false positive test
…, happy path, spies, mock
…ere used only once
…ate targets tests
…ole object structure
Things done after review
Self Review
|
expect(nxDevkitMockModule.logger.warn).toHaveBeenCalledTimes(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.
expect(nxDevkitMockModule.logger.warn).toHaveBeenCalledTimes(0); | |
}); | |
expect(nxDevkitMockModule.logger.warn).not.toHaveBeenCalled(); | |
}); | |
expect(nxDevkitMockModule.logger.warn).toHaveBeenCalledTimes(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.
expect(nxDevkitMockModule.logger.warn).toHaveBeenCalledTimes(0); | |
}); | |
expect(nxDevkitMockModule.logger.warn).not.toHaveBeenCalled(); | |
}); |
let normalizeCreateNodesOptionsSpy: MockInstance; | ||
let isEnvProjectSpy: MockInstance; | ||
let isPkgSpy: MockInstance; | ||
let verdaccioTargetsSpy: MockInstance; | ||
let getEnvTargetsSpy: MockInstance; | ||
let updateEnvTargetNamesSpy: MockInstance; | ||
|
||
beforeEach((): void => { | ||
normalizeCreateNodesOptionsSpy = vi | ||
.spyOn(normalizeCreateNodesSpyModule, 'normalizeCreateNodesOptions') | ||
.mockReturnValue(normalizedOptions); | ||
isEnvProjectSpy = vi | ||
.spyOn(environmentTargetsModule, 'isEnvProject') | ||
.mockReturnValue(true); | ||
isPkgSpy = vi | ||
.spyOn(packageTargetsSpyModule, 'isPkgProject') | ||
.mockReturnValue(true); |
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.
General best practices for setup spy's and configuring spy's:
- setup in describe
- configuring with potential defaults in beforeEach
- actual mock return in the it block
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.
Thanks for the tests!
I left some comments
No description provided.