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

Add unit tests for CLI and add flow compilation #186

Merged
merged 13 commits into from
Oct 5, 2017
Merged

Conversation

evenstensberg
Copy link
Member

@evenstensberg evenstensberg commented Sep 21, 2017

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

@evenstensberg
Copy link
Member Author

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.

@evenstensberg
Copy link
Member Author

Could anyone review this?

Copy link
Contributor

@okonet okonet left a 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",
Copy link
Contributor

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"
Copy link
Contributor

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.

@evenstensberg
Copy link
Member Author

Yep, sure. Mocha was in old webpack, was easier to port those

@evenstensberg
Copy link
Member Author

@okonet done!

options[name] = true;
}
//eslint-disable-next-line
if (name && options[name] == true) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't be ===?

Copy link
Member Author

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

Copy link
Member Author

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
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch!

Copy link
Member Author

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

@ematipico
Copy link
Contributor

Some tests are failing on Node 5 and 4

@evenstensberg
Copy link
Member Author

Yep, cause we use include, changed in the feature PR

@ematipico
Copy link
Contributor

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")) {
Copy link
Contributor

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

@evenstensberg
Copy link
Member Author

Any comments?

@ematipico
Copy link
Contributor

It looks fine to me, there are just some conflicts but overall looks good

ianjsikes and others added 8 commits September 29, 2017 23:59
* 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
@evenstensberg
Copy link
Member Author

evenstensberg commented Sep 29, 2017

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?

@ematipico
Copy link
Contributor

Fine by me. We also added the removing of the types before publishing, which is awesome!

@evenstensberg evenstensberg merged commit c8633c0 into master Oct 5, 2017
@evenstensberg evenstensberg deleted the cli-tests branch October 5, 2017 20:57
evenstensberg added a commit that referenced this pull request Oct 22, 2017
* 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
evenstensberg added a commit that referenced this pull request Oct 22, 2017
* 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
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.

4 participants