Skip to content
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

Run tests e2e against an npm pack && npm installed ts-node #1032

Merged
merged 6 commits into from
May 11, 2020

Conversation

cspotcode
Copy link
Collaborator

This is necessary to test that our entrypoints are working correctly with package.json "exports".

This change runs npm pack to create a tarball, then npm installs it into tests/node_modules/

The tests require('ts-node/register') and exec ./node_modules/.bin/ts-node so it matches how a consumer invokes ts-node.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.6%) to 81.344% when pulling 95cb9bc on ab/e2e-tests into c1ae9a0 on master.

@coveralls
Copy link

coveralls commented May 10, 2020

Coverage Status

Coverage increased (+0.4%) to 81.137% when pulling b56dfde on ab/e2e-tests into a335834 on master.

await execP(`npm install`, { cwd: TEST_DIR })
const packageLockPath = join(TEST_DIR, 'package-lock.json')
existsSync(packageLockPath) && unlinkSync(packageLockPath)
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if these a way to do this outside of the test suite or possibly a separate set of tests? Either way this looks like a great start at coverage.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can definitely move the npm pack into our npm build. That would be better since it would npm pack using the same node and npm versions as we use to publish.

Are you thinking you want 2x sets of tests, one unit tests, the other doing these e2e-style tests against an npm install?

I thought about that but I wasn't sure how useful it'd be since the tests mostly look e2e-style already. Your call though, happy to split things out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it how it is then, I don't have strong opinions either way but it's great to know you thought about this.

@cspotcode
Copy link
Collaborator Author

@blakeembrey This is ready for (one more) review. I moved the npm pack into a build step instead of a test step. Installation still happens at test time, in case the goal is to e2e test against an older version of node & npm.

Here are the changes since your last review to make it a little easier.
https://github.com/TypeStrong/ts-node/compare/2869699..b56dfde

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants