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

Jest and Inquirer Integration [WIP] #5

Merged
merged 15 commits into from
Dec 20, 2016

Conversation

evenstensberg
Copy link
Member

Commit allows further testing and integration with inquirer and jest
for our TDD approach. Regex could be changed to have specific test
names for our purposes.

Commit allows further testing and integration with inquirer and jest
for our TDD approach. Regex could be changed to have specific test
names for our purposes.
Installed rxJS and our tests are running in the travis validations.
@evenstensberg evenstensberg changed the title feat: testing-and-inquirer Jest and Inquirer Integration Dec 17, 2016
@@ -0,0 +1,12 @@
const Rx = require('rx');
const {inquirerInput} = require('./utils/inquirer-questions.js');
Copy link

Choose a reason for hiding this comment

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

Maybe name this as inquirer-types or inquirer-question-types?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that's probably the best, I'll change that up

@@ -14,17 +14,32 @@
"main": "./bin/cli.js",
"scripts": {
"lint": "eslint ./lib",
"install-commit-validator": "fit-commit-js install"
"install-commit-validator": "fit-commit-js install",
"test": "jest"
Copy link

Choose a reason for hiding this comment

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

Would be good to add these info to readme.

Copy link
Member Author

Choose a reason for hiding this comment

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

Could do later, when we put the entire readme up?

Copy link

Choose a reason for hiding this comment

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

Also good to add a test-watch script?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should also lint the tests, when we don't do it, the coding style of the tests will not be consistent with the style of the code under /lib

Copy link
Member Author

Choose a reason for hiding this comment

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

Doing what @pksjce said we need listed probably on wednesday. Got midterms. @DanielaValero Yes! Will do! Just have to get something testable up first, collecting information so I've got enough knowledge to do this 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also say that a watch for the test would be quite helpful when we want to code with TDD


inquirer.prompt(questions).ui.process.subscribe(
(ans) => {
console.log(ans);
Copy link

Choose a reason for hiding this comment

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

How to test this though?

Copy link
Member Author

Choose a reason for hiding this comment

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

For yourself: Open in GH desktop: npm link could need a sudo flag. Type webpack-cli --init. Through jest: Simulate an inq instance if possible.

Copy link
Member Author

@evenstensberg evenstensberg Dec 17, 2016

Choose a reason for hiding this comment

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

I could do it at a later stage though, this is just to set up the inquirer prompt, no need for testing in Jest yet.

Changes name to better reflect its usage.
@evenstensberg
Copy link
Member Author

FWIW - We can mock manually or use mocking patterns to do this automatically.

Integrated new test suites and trying to get it work nicely with
observable sequences.
@evenstensberg
Copy link
Member Author

Don't merge yet, [WIP]

@evenstensberg evenstensberg changed the title Jest and Inquirer Integration Jest and Inquirer Integration [WIP] Dec 18, 2016
obs.next(inquirerInput('outputLogic',
'What is the name of the output directory in your application?'
));
obs.onCompleted();
Copy link

Choose a reason for hiding this comment

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

Instead you could,

const questions = [
	inquirerInput('entryLogic','What is the name of the entry point in your application?'), 
	inquirerInput('outputLogic','What is the name of the output directory in your application?')];

module.exports = Rx.Observable.from(questions);

});
inquirer.prompt(questions).ui.process.subscribe(function (response) {
expect(response.entryLogic).toBe('index.js')
expect(response.outputLogic).toBe('output.js')
Copy link

@pksjce pksjce Dec 19, 2016

Choose a reason for hiding this comment

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

I don't think you need to test if inquirer works. You only need to test what we do with the answers like they do in eslint.

@DanielaValero
Copy link
Contributor

DanielaValero commented Dec 19, 2016

Hi @ev1stensberg

In spite of the work not yet being completed, therefore theoretically ready for a code review, I have done a quick check on the current state of your branch, and would like to share some ideas, perhaps you've got them already on your sight, but wanted to share them in case you don't.

  • In order to fix the travis error, we need to add 'use strict' on top of the test files, this is because in versions of node < 6, the block-scoped declarations of es2015 where supported only on strict mode
  • When we enable lintin on the test files, there will be some easy fixes that you will be able to apply with the help of the editorconfig and the beautifier, however, eslint is throwing no-undef on jasmine functions, such as describe, in order to fix them we would need to add to the list of environments in the eslint settings, jasmine: true
  • I'd suggest that for the test files, we use the same name of the file under ./lib, for which we are doing the testing. We could follow the same style as in webpack for the name, in there, the file has a sufix: .test.js, when we do this, for example a test for: inquirer.js, would be: inquirer.test.js. This way, would be more straight forward to find the test of the file we are at the moment looking at.

Does it make sense?

@evenstensberg evenstensberg changed the base branch from master to hotfix/testing December 20, 2016 17:34
@evenstensberg evenstensberg merged commit 9e16673 into hotfix/testing Dec 20, 2016
@evenstensberg evenstensberg deleted the feature/test-and-inquirer branch December 20, 2016 17:36
@evenstensberg evenstensberg mentioned this pull request Dec 20, 2016
pksjce pushed a commit that referenced this pull request Dec 20, 2016
* Jest and Inquirer Integration [WIP] (#5)

* feat: testing-and-inquirer

Commit allows further testing and integration with inquirer and jest
for our TDD approach. Regex could be changed to have specific test
names for our purposes.

* feat: installed rx and test on travis

Installed rxJS and our tests are running in the travis validations.

* hotfix: Change name

Changes name to better reflect its usage.

* feat: new test suites

Integrated new test suites and trying to get it work nicely with
observable sequences.

* fix - Adds changes to observable questions

* fix - Try to pass the build

* hotfix: New test pattern

Manually mock inquirer, allows clean test stdin and a faster testing
procedure.

* hotfix: Travis stuff

* Hotfix: travis

* hotfix: yarn

* hotfix: travis

* hotfix: new travis

* hotfix

* hotfix2

* hotfix: Use ES6 + prepare to squash

* Fix the build
evenstensberg pushed a commit that referenced this pull request Dec 21, 2016
Hotfix/testing (#8)

* Jest and Inquirer Integration [WIP] (#5)

* feat: testing-and-inquirer

Commit allows further testing and integration with inquirer and jest
for our TDD approach. Regex could be changed to have specific test
names for our purposes.

* feat: installed rx and test on travis

Installed rxJS and our tests are running in the travis validations.

* hotfix: Change name

Changes name to better reflect its usage.

* feat: new test suites

Integrated new test suites and trying to get it work nicely with
observable sequences.

* fix - Adds changes to observable questions

* fix - Try to pass the build

* hotfix: New test pattern

Manually mock inquirer, allows clean test stdin and a faster testing
procedure.

* hotfix: Travis stuff

* Hotfix: travis

* hotfix: yarn

* hotfix: travis

* hotfix: new travis

* hotfix

* hotfix2

* hotfix: Use ES6 + prepare to squash

* Fix the build

Project Restructure
pksjce pushed a commit to kalcifer/webpack-cli that referenced this pull request Dec 22, 2016
* feat: testing-and-inquirer

Commit allows further testing and integration with inquirer and jest
for our TDD approach. Regex could be changed to have specific test
names for our purposes.

* feat: installed rx and test on travis

Installed rxJS and our tests are running in the travis validations.

* hotfix: Change name

Changes name to better reflect its usage.

* feat: new test suites

Integrated new test suites and trying to get it work nicely with
observable sequences.

* fix - Adds changes to observable questions

* fix - Try to pass the build

* hotfix: New test pattern

Manually mock inquirer, allows clean test stdin and a faster testing
procedure.

* hotfix: Travis stuff

* Hotfix: travis

* hotfix: yarn

* hotfix: travis

* hotfix: new travis

* hotfix

* hotfix2

* hotfix: Use ES6 + prepare to squash
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