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

WIP: Build and run tests with webpack #770

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

bcheidemann
Copy link
Contributor

@bcheidemann bcheidemann commented Mar 21, 2021

Adds the option to build and run tests with webpack using the command npm run test:webpack. (Similar to npm run test:manual in that it spins up a local server)

@bcheidemann
Copy link
Contributor Author

@humphd Is this the kind of thing you were talking about?

@codecov-io
Copy link

codecov-io commented Mar 21, 2021

Codecov Report

Merging #770 (05ea9e7) into master (c0a41d6) will increase coverage by 0.16%.
The diff coverage is 96.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #770       /-   ##
==========================================
  Coverage   86.89%   87.06%    0.16%     
==========================================
  Files          16       20        4     
  Lines        1740     1770       30     
==========================================
  Hits         1512     1541       29     
- Misses        228      229        1     
Impacted Files Coverage Δ
shims/fs.js 95.83% <95.83%> (ø)
shims/buffer.js 100.00% <100.00%> (ø)
shims/path.js 100.00% <100.00%> (ø)
shims/providers/default.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f8c9732...05ea9e7. Read the comment docs.

package.json Outdated
@@ -46,14 47,17 @@
},
"dependencies": {
"es6-promisify": "^6.1.0",
"minimatch": "^3.0.4"
"minimatch": "^3.0.4",
"node-polyfill-webpack-plugin": "^1.0.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

These additional deps look like they can move to devDependencies

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'll move those over 👍

@@ -4,7 4,7 @@ const bufferDefault = require('../../../shims/buffer').default;
const bufferNamed = require('../../../shims/buffer').Buffer;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's rebase on master to pick up these changes there vs. duplicating.

entry: path.resolve(__dirname, './webpack-tests.js'),
resolve: {
alias: {
'fsProvider': path.resolve(__dirname, '../shims/providers/default'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Forgive my webpack ignorance here: can we not use Filer in this setup the way you're outlining in the README? It would be great if we had test code that did what the README suggests, so we know if it breaks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean aliasing fs, path and Buffer? We can definitely do that but obviously we'd need to refactor the shim tests to require fs, path and Buffer instead of the shims so those tests would have to be separated from the rest of the tests. I think that makes sense though as they're webpack specific.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, that's what I was thinking. Given that there are a few ways to do this, having adequate test coverage of all of them is my goal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @humphd, I'm still working on this PR but found an issue with the way we're shimming the path module. In short, the alias messes up the import of the path module in filer (which I'd previously overlooked) and as such the path module ends up missing a lot of the methods (all the ones not explicitly replaced by filer). It should be possible to write a webpack plugin which resolves the path module correctly. Are you happy for me to go ahead with this and to make a separate PR for it?

Copy link
Contributor

Choose a reason for hiding this comment

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

@bcheidemann I think that sounds like a good idea. Thanks for pushing on this code a bit, it's great that testing is already discovering ways we can make it better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem! I'm happy to do it and it's teaching me a lot :D I just wish I had more time to work on it at the moment!

@bcheidemann bcheidemann changed the title Build and run tests with webpack WIP: Build and run tests with webpack Apr 4, 2021
@humphd
Copy link
Contributor

humphd commented Apr 6, 2021

Ping me when you want reviews on these.

@bcheidemann
Copy link
Contributor Author

No problem 👍

@bcheidemann
Copy link
Contributor Author

Ping me when you want reviews on these.

I will come back to these after #771 is merged as I think it makes sense to use the webpack plugin to build these tests. Also, if we move the plugin to it's own repo (as discussed in #771) would you want to move these tests to that repo or leave them here?

@humphd
Copy link
Contributor

humphd commented Apr 18, 2021

I think doing it in this repo is probably the best idea, since it has CI setup already, and is so closely related to the other code. I'm more wondering about reducing the bundle size for Filer for cases where people aren't using the webpack plugin. We could write a separate set of build/test scripts to be run with npm-run-all or something that builds it beside vs. as part of Filer.

Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

One nit and the lock file needs to be regenerated, otherwise looks good.

@@ -46,14 47,17 @@
},
"dependencies": {
"es6-promisify": "^6.1.0",
"path": "^0.12.7",
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this, it's a node built-in module.

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