-
Notifications
You must be signed in to change notification settings - Fork 8
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
Create jasmine-parameterized package #1738
Conversation
@msmithNI, can you buddy this PR for me? |
change/@ni-jasmine-parameterized-7779e285-bc01-469c-8e6d-ae0b039d8273.json
Show resolved
Hide resolved
Co-authored-by: Jesse Attas <jattasNI@users.noreply.github.com>
@@ -1,6 +1,7 @@ | |||
/* eslint-disable max-classes-per-file */ | |||
import { customElement, html, ref } from '@microsoft/fast-element'; | |||
import { MenuItem as FoundationMenuItem } from '@microsoft/fast-foundation'; | |||
import { parameterizeNamedList } from '@ni/jasmine-parameterized/dist/esm/parameterized'; |
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.
Thinking about the API a bit, I think we should make the following changes:
- Don't expose the parameterize helper function (i.e. don't export it or put it in the readme) and rename parameterizeNamedList to parameterizeSpec
- Make it so the import is top-level in the package, i.e.
import { parameterizeSpec } from '@ni/jasmine-parameterized';
. This should be doable with conditional exports for import and require: https://nodejs.org/api/packages.html#conditional-exports - We create the cjs build and we should test it in node
- See how the xliff package uses the
jasmine
node cli:"test": "jasmine" - And configures the node tests: https://github.com/ni/nimble/blob/aa6943c5910766f77c69a47bee2406e6210ac8ce/packages/xliff-to-json-converter/spec/support/jasmine.json
- jasmine runner docs: https://jasmine.github.io/setup/nodejs.html
- See how the xliff package uses the
It shouldn't be in this PR but this allows us to make something like parameterizeSuite
to align with parameterizeSpec
in the future, something like:
const sizes = [
{ name: 'small', value: 2 },
{ name: 'medium', value: 5 },
{ name: 'large', value: 10}
] as const;
parameterizeSuite(sizes, (suite, suiteName, suiteValue) => {
suite(`A ${suiteName} rain`, () => {
const rainTests = [
{ name: 'cats-and-dogs', type: 'idiom' },
{ name: 'frogs' type: 'idiom'},
{ name: 'men', type: 'lyrics'}
] as const;
parameterizeSpec(rainTests, (spec, name, value) => {
spec(`of type ${name} exist`, () => {
expect(value.type).toBeDefined();
expect(suiteValue.value).toBeDefined();
});
}, {
'cats-and-dogs': fit,
frogs: xit
});
});
}, {
small: xdescribe
});
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.
Don't expose the parameterize helper function (i.e. don't export it or put it in the readme) and rename parameterizeNamedList to parameterizeSpec
I've renamed parameterizeNamedList
to parameterizeSpec
. I also no longer am exporting parameterize
or including it in the readme. However, my question is: Should we remove parameterize
altogether? It isn't used by anything.**
Make it so the import is top-level in the package, i.e. import { parameterizeSpec } from '@ni/jasmine-parameterized';. This should be doable with conditional exports for import and require: https://nodejs.org/api/packages.html#conditional-exports
Done, but let me know if there is something I should've done differently.
We create the cjs build and we should test it in node
Done. I also updated karma.conf.json
to only run tests on the esm
build, but should karma.conf.json
still be configured to run for both esm
and commonjs
?
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.
Should we remove parameterize altogether? It isn't used by anything.**
It is used in the parameterizeSpec implementation. Don't think I follow what is being proposed.
parameterize<ObjectFromNamedList<T>>(testCases, test, specOverrides); |
Done. I also updated karma.conf.json to only run tests on the esm build, but should karma.conf.json still be configured to run for both esm and commonjs?
Was mulling over it a bit and realized that the browser usage was being pushed through webpack, so it was really testing the webpack config and the node usage wasn't relying on the cjs import as the test file itself was using the es6 import
statement to reference the dependency instead of the cjs format require
statement.
Modern versions of browsers and node support es6 modules so I simplified and removed the cjs parts of the build. I switched the TS config to use the newer "Node16" for the module format (which is just es6 modules as supported by node).
So now we are actually using esm js files and I got esm tests to work in karma .
I also read the npm entrypoints and typescript npm entrypoint docs and modified the format of the entrypoints to match that. For some reason I needed the Fall-back for older versions of TypeScript
that I couldn't figure out but guess it's not a big deal.
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 updates to the branch!
Even though the TS docs and following comment say it's just a fallback :/ microsoft/TypeScript#44501 (comment)
This reverts commit ff96d9c.
change/@ni-jasmine-parameterized-7779e285-bc01-469c-8e6d-ae0b039d8273.json
Outdated
Show resolved
Hide resolved
Co-authored-by: Milan Raj <rajsite@users.noreply.github.com>
Pull Request
🤨 Rationale
This is part of #1551
Based on this discussion, we decided to create a new npm package for
jasmine-parameterized
rather than have it be exported from an existing nimble package.👩💻 Implementation
jasmine-parameterized
that contains the existingparameterized.ts
andtests\parameterized.spec.ts
parameterized.ts
andtests\parameterized.spec.ts
fromnimble-components
nimble-components
to useparameterizeSpec
fromjasmine-parameterized
🧪 Testing
dist
directory (without tests),package.json
, andREADME.md
✅ Checklist