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

Replace local tests with E2E tests #60

Merged
merged 27 commits into from
Aug 14, 2020

Conversation

andrewiggins
Copy link
Collaborator

@andrewiggins andrewiggins commented Aug 12, 2020

While working on #59, I wanted a way to test that our rollup code worked as expected. That rabbit hole lead me here 😅

This PR replaces the "local" test suite we had with what I'm calling E2E tests. The e2e-test directory contains sub directories that model how a user of karmatic might use karmatic. Each subdir contains a package.json, some source code, and some tests. To run the tests we just run npm install in each directory and run karmatic in that directory (the run-e2e-tests.mjs script automates this)

Each e2e test package.json includes karmatic using a local file:../.. reference so the local karmatic source is symlinked into the node_modules folder of the e2e tests so they test the local build output.

While this kind of test is a little overkill for karmatic now, I think it really becomes useful in light of #59 because of how we do webpack/rollup detection. Since we determine which bundler to use based on what is installed, we need to run tests in directories that either have webpack or rollup installed, not both. Because of this, we can't just install webpack and rollup and devDeps cause our local tests will only ever run using webpack since that is the preferred bundler if it present. This testing infra allows us to use different kinds of setups to verify karmatic works as expected.

I hope a lot of this becomes easier with npm v7's workspace support.

EDIT: Oh, I forgot to mention - the webpack-default test includes all the tests that were previous test suite

@@ -64,6 +64,6 @@ function run(str, opts, isWatch) {
'\n'
);
}
process.exit(err.code || 1);
process.exit(typeof err.code == 'number' ? err.code : 1);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Caught this bug while running these tests - some NodeJS errors have the .code property set to a string, which if you pass here will cause the process to exit cleanly

@andrewiggins andrewiggins force-pushed the e2e-tests branch 4 times, most recently from 66f8f4d to a83f6f6 Compare August 12, 2020 22:53
Copy link
Collaborator

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

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

This is awesome 🙌

@andrewiggins
Copy link
Collaborator Author

To unblock rollup integration, I'm going to go ahead and merge this change, but I'm happy to address any other concerns people have. Just @-mention me :)

@andrewiggins andrewiggins merged commit 6be5fa7 into developit:master Aug 14, 2020
@andrewiggins andrewiggins deleted the e2e-tests branch August 14, 2020 00:28
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.

2 participants