-
Notifications
You must be signed in to change notification settings - Fork 573
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
refactor: set default test options #1704
Conversation
5e4b887
to
c12977a
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.
lgtm :)
import * as config from '../../../lib/config'; | ||
import { Options, ShowVulnPaths, TestOptions } from '../../../lib/types'; | ||
|
||
export function setDefaultTestOptions( |
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 believe we should keep adding jest-unit test for these new modules
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.
how are these structured? Right now I am dumping all new tests into top level test directory because of the jest pattern restrictions 😢 can we update this to allow us to add tests in correct folder structures instead?
- code:
unit/src/lib/index.ts
- test:
test/lib/index.spec.ts
? Maybe for nowtest/jest/unit/lib/index.spec.ts
until we fully migrate to Jest?
It will be hard to separate jest tests later from system/acceptance/unit etc
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.
Test added, please advise if it can move somewhere better than top level of test directory
|
||
export function setDefaultTestOptions(options: Options): Options & TestOptions { | ||
const svpSupplied = (options['show-vulnerable-paths'] || '') | ||
.toString() |
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.
this essentially adds support for --show-vulnerable-paths
to be treated as --show-vulnerable-paths=true
WDYT?
Otherwise if you run test with snyk test --show-vulnerable-paths
you get a bad error that says
toLowerCase is not a function
because it is not a string. Or alternative is to add validation for this options and throw outside of this function somewhere probably
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.
👍 this sounds in line with how arg parsing libraries should treat this
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.
@gitphill while @aviadhahami is off, could you help 👀 ?
c47c9db
to
0545ea6
Compare
0545ea6
to
249a43d
Compare
@@ -13,8 +13,7 @@ export type DepTree = legacyApi.DepTree; | |||
export type ShowVulnPaths = 'none' | 'some' | 'all'; | |||
|
|||
export interface TestOptions { | |||
traverseNodeModules: boolean; | |||
interactive: boolean; |
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.
this is a protect option for wizard only
|
||
export function setDefaultTestOptions(options: Options): Options & TestOptions { | ||
const svpSupplied = (options['show-vulnerable-paths'] || '') | ||
.toString() |
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.
👍 this sounds in line with how arg parsing libraries should treat this
it('defaults to show-vulnerable-paths:some & org from config when no options passed in', () => { | ||
const updated = setDefaultTestOptions({ path: '/' }); | ||
expect(updated).toEqual({ | ||
org: undefined, |
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.
Just curious, in the jest's equals logic, is org: undefined
same as not having org
key at all?
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 does indeed!
249a43d
to
0f2ee40
Compare
Just a nit, noticed a typo in the commit message, which would propagate it to the release notes: features:
- delete vuln paths option once transofrmed + tests
+ delete vuln paths option once transformed |
Add tests for the setDefaultTestOptions()
0f2ee40
to
442e37f
Compare
Expected release notes (by @lili2311) features: others (will not be included in Semantic-Release notes):
|
What does this PR do?
refactor settings default test options so it can be re-used in another command that relies on test running first