-
Notifications
You must be signed in to change notification settings - Fork 46
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
test: consuming this library in various scenarios #164
base: master
Are you sure you want to change the base?
Conversation
This reverts commit 83cdebc.
jest.config.js
Outdated
@@ -4,4 +4,5 @@ module.exports = { | |||
}, | |||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'], | |||
testEnvironment: 'node', | |||
rootDir: './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.
Jest would execute the .spec files in the directory test-lib-consumption
without that.
da12f59
to
6e3060b
Compare
test-lib-consumption/main.spec.mts
Outdated
it(`scenario "${scenarioDirectory.name}"`, async () => { | ||
const pathToDirectory = path.join(PATHS.SCENARIOS_DIRECTORY, scenarioDirectory.name); | ||
$.cwd = pathToDirectory; | ||
await $`npm install --package-lock=false`; |
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.
npm install
is used here (instead of yarn) because for the scenarios it does not matter - they just fetch dependencies from Verdaccio and that's it.
a4dffcd
to
cbe8a77
Compare
cbe8a77
to
1cbebe2
Compare
This looks like a fantastic change. I am so sorry for not getting back to you sooner! I have been walking through a bit of burnout. I hope to look at this thoroughly in the new year |
No problem! |
@pkerschbaum I love the goal and outcome of this change. Something I am thinking about is that this is a lot of code and complexity to add to this (little) package. I wonder if there is some way to pull what you have done out into another place (eg a package) which then |
@alexreardon I was actually able to create a package |
I also updated the description of the PR. |
Problem
tiny-invariant
should compile and run in various setups. Be it Node-CJS, Node-ESM, TypeScript projects with various configurations, in Browsers, etc.On this matter we had some troubles in the past (#144, #151) and we have a new issue (#162).
Iterating on this topic - package consumption in different scenarios - is difficult and error-prone at the moment.
Proposed Solution
Add tests which validate that
tiny-invariant
compiles and runs in different scenarios.This PR implements a package.json script
test:pkg-consumption
which uses@pkerschbaum/pkg-consumption-test
to run "package consumption scenarios".Those scenarios are implemented in /test-pkg-consumption.
Four scenarios are implemented with this PR. Locally I added a fifth scenario for #162, and it successfully reproduces the issue.
In other words, when working on a fix for #162 one can just work against that failing scenario, while making sure that the others don't break.
Notes