-
-
Notifications
You must be signed in to change notification settings - Fork 611
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
Add unit tests for CLI and add flow compilation #186
Conversation
Once this gets a ok to merge, we'd need to remove the local import, but it's to emphasize that the CLI tests runs well locally if you clone and run the branch. |
Could anyone review this? |
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.
I'm not sure why you have chosen Mocha for tests since we already have Jest in place.
Also, Jest allows create custom snaphotSerializers that would allow using snapshots to test the output.
Do you think you could switch your tests to Jest?
package.json
Outdated
"husky": "^0.14.3", | ||
"jest": "^20.0.4", | ||
"jest-cli": "^20.0.4", | ||
"lint-staged": "^4.1.3" | ||
"lint-staged": "^4.1.3", | ||
"mocha": "^3.5.3", |
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.
We're using Jest for tests. Why is this needed?
package.json
Outdated
"lint-staged": "^4.1.3", | ||
"mocha": "^3.5.3", | ||
"prettier-eslint-cli": "^4.3.2", | ||
"should": "^13.1.0" |
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.
Same, jest already has everything we need.
Yep, sure. Mocha was in old webpack, was easier to port those |
@okonet done! |
options[name] = true; | ||
} | ||
//eslint-disable-next-line | ||
if (name && options[name] == true) { |
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.
Shouldn't be ===
?
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.
Implemented by webpack/core. You should just look at the test for now
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.
Also, let's keep it non-strict equal, cause it could be stringified
const spawn = require("child_process").spawn; | ||
|
||
function loadOptsFile(optsPath) { | ||
// Options file parser from Mocha |
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.
Comment can be removed as we decided to stick with Jest
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.
Nice catch!
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.
Actually, this should be kept, if you see next line
Some tests are failing on Node 5 and 4 |
Yep, cause we use |
Great, so it's under control :) |
bin/webpack.js
Outdated
var localCLI = resolveCwd.silent("webpack-cli/bin/webpack"); | ||
|
||
if (process.argv.slice(2).includes("init")) { |
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.
.includes
is not supported by Node 5 and 4. We need to change it. Also below
http://node.green/#ES2015-built-ins-well-known-symbols-Symbol-match--String-prototype-includes
Any comments? |
It looks fine to me, there are just some conflicts but overall looks good |
* Add template files for loader yeoman generator * Create yeoman generator for a webpack loader project * Add tests for loader-generator * Add `mkdirp` dependency for loader-generator * Add function to create yeoman env and run loader-generator * Add `generate-loader` command to webpack-cli * Copy loader templates from proper directory * Add template files for plugin generator * Create yeoman generator for webpack plugins * Add function to create yeoman env and run plugin generator * Add cli command to generate plugin * Register generate- commands in yargs * Add template files for loader examples and tests * Copy loader test and example template files in generator * Add template files for plugin examples and tests * Copy plugin test and example template files in generator * Refactor generator file copying, switch .includes with .indexOf in CLI arg parsing * Change `indexOf('foo') > -1` to `indexOf('foo') >= 0` * Factor out generator copy utilities into separate module * Rewrite generators using a function that returns a customized generator class * Fix linting errors * Remove //eslint-disable lines from template files
# Conflicts: # bin/webpack.js # package.json
V4 failing cause there's too many async operations going on, preventing the binCases to fully run. LGTM for now I guess. @ematipico your opinion? |
Fine by me. We also added the removing of the types before publishing, which is awesome! |
* add unit tests for everything and flow compilation * add travis builds * add cli to signature & add ignore to trash code * port to jest * remove redundant cli command * Feature/generate loader (#183) * Add template files for loader yeoman generator * Create yeoman generator for a webpack loader project * Add tests for loader-generator * Add `mkdirp` dependency for loader-generator * Add function to create yeoman env and run loader-generator * Add `generate-loader` command to webpack-cli * Copy loader templates from proper directory * Add template files for plugin generator * Create yeoman generator for webpack plugins * Add function to create yeoman env and run plugin generator * Add cli command to generate plugin * Register generate- commands in yargs * Add template files for loader examples and tests * Copy loader test and example template files in generator * Add template files for plugin examples and tests * Copy plugin test and example template files in generator * Refactor generator file copying, switch .includes with .indexOf in CLI arg parsing * Change `indexOf('foo') > -1` to `indexOf('foo') >= 0` * Factor out generator copy utilities into separate module * Rewrite generators using a function that returns a customized generator class * Fix linting errors * Remove //eslint-disable lines from template files * add unit tests for everything and flow compilation * add travis builds * add cli to signature & add ignore to trash code * port to jest * remove redundant cli command * rebase against master
* chore: Use prettier (#173) * build: Add webpack lint settings and style code with eslint --fix We now use the webpack eslint settings that make sense in the cli. Also use the new --fix of eslint to automatically beautify the code * Add additional .eslintrc to /bin to remove unrelated eslint errors * build: Add jest-cli as dev dependency * style: fix lintin errors and coding style according to webpack settings * build: update dependencies and add package-lock to repo * feat: Require quotes only in property names that require it * chore: Add again removed settings by merge conflict solving * tests: Fix failing test * chore: Use husky instead of pre-commit pre-commit package stopped working. See observing/pre-commit#113 husky also requires less boilerplate in the package.json * [Feature] Added support to Flow inside transformations (#174) * [FLOW] Implemented interfaces and flow types inside the transformations * [FLOW] first commit * Added flwo to two other files * Reviewed interfaces * Created different intefaces for expressions * Fixed rest of trasformations * More developments * Updated code after code review * Fixed failing tests * Removed yarn file * Applied linting * Updated packages * Applied lint style to the imports due to code review * docs: Documentation for migrate (#175) * initial draft of migrate documentation * formatting * formatting * added summary of migrate changes * maintain consistent usage of user through documentation * Feature/generate loader (#183) * Add template files for loader yeoman generator * Create yeoman generator for a webpack loader project * Add tests for loader-generator * Add `mkdirp` dependency for loader-generator * Add function to create yeoman env and run loader-generator * Add `generate-loader` command to webpack-cli * Copy loader templates from proper directory * Add template files for plugin generator * Create yeoman generator for webpack plugins * Add function to create yeoman env and run plugin generator * Add cli command to generate plugin * Register generate- commands in yargs * Add template files for loader examples and tests * Copy loader test and example template files in generator * Add template files for plugin examples and tests * Copy plugin test and example template files in generator * Refactor generator file copying, switch .includes with .indexOf in CLI arg parsing * Change `indexOf('foo') > -1` to `indexOf('foo') >= 0` * Factor out generator copy utilities into separate module * Rewrite generators using a function that returns a customized generator class * Fix linting errors * Remove //eslint-disable lines from template files * Add unit tests for CLI and add flow compilation (#186) * add unit tests for everything and flow compilation * add travis builds * add cli to signature & add ignore to trash code * port to jest * remove redundant cli command * Feature/generate loader (#183) * Add template files for loader yeoman generator * Create yeoman generator for a webpack loader project * Add tests for loader-generator * Add `mkdirp` dependency for loader-generator * Add function to create yeoman env and run loader-generator * Add `generate-loader` command to webpack-cli * Copy loader templates from proper directory * Add template files for plugin generator * Create yeoman generator for webpack plugins * Add function to create yeoman env and run plugin generator * Add cli command to generate plugin * Register generate- commands in yargs * Add template files for loader examples and tests * Copy loader test and example template files in generator * Add template files for plugin examples and tests * Copy plugin test and example template files in generator * Refactor generator file copying, switch .includes with .indexOf in CLI arg parsing * Change `indexOf('foo') > -1` to `indexOf('foo') >= 0` * Factor out generator copy utilities into separate module * Rewrite generators using a function that returns a customized generator class * Fix linting errors * Remove //eslint-disable lines from template files * add unit tests for everything and flow compilation * add travis builds * add cli to signature & add ignore to trash code * port to jest * remove redundant cli command * rebase against master * ast for devServer (#185) * feat: replace yarn backup w/ normal yarn (#160) * feat: replace yarn backup w/ normal yarn * upgrade npm & remove yarn * Use yarn if available (#189) * bump version to 1.3.4 * update package.json * 1.3.5 * prepublish -> postinstall * 1.3.6 * temp fix to prepublish issue * 1.3.7 * add propper post install * 1.3.8 * re-add manual build step * 1.3.9 * refactor * bump version * disable published pkg * add ignore patterns * add more ignore patterns for npm
This PR enables us to test the webpack CLI as it stands in core, which in turns allows us to merge into the core repository