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

Refactor addon-jest to use a parameter-based pattern #3678

Merged
merged 6 commits into from
Jul 4, 2018

Conversation

tmeasday
Copy link
Member

@tmeasday tmeasday commented May 29, 2018

For #3625 -- this one was a little different as the current API doesn't quite fit the old pattern. But I think I've brought it as close as possible to fitting the parameters philosophy.

@codecov
Copy link

codecov bot commented May 29, 2018

Codecov Report

Merging #3678 into master will decrease coverage by 0.05%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #3678      +/-   ##
=========================================
- Coverage   41.35%   41.3%   -0.06%     
=========================================
  Files         455     455              
  Lines        5184    5191       +7     
  Branches      900     902       +2     
=========================================
  Hits         2144    2144              
- Misses       2496    2501       +5     
- Partials      544     546       +2
Impacted Files Coverage Δ
addons/jest/src/index.js 0% <0%> (ø) ⬆️

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 759d741...1e3d925. Read the comment docs.

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

LGTM w/ small typo

- **options.results**: OBJECT jest output results. *mandatory*
- **filesExt**: STRING test file extention. *optionnal*. This allow you to write "MyComponent" and not "MyComponent.test.js". It will be used as regex to find your file results. Default value is `((\\.specs?)|(\\.tests?))?(\\.js)?$`. That mean it will match: MyComponent.js, MyComponent.test.js, MyComponent.tests.js, MyComponent.spec.js, MyComponent.specs.js...
* **options.results**: OBJECT jest output results. _mandatory_
* **filesExt**: STRING test file extention. _optionnal_. This allow you to write "MyComponent" and not "MyComponent.test.js". It will be used as regex to find your file results. Default value is `((\\.specs?)|(\\.tests?))?(\\.js)?$`. That mean it will match: MyComponent.js, MyComponent.test.js, MyComponent.tests.js, MyComponent.spec.js, MyComponent.specs.js...
Copy link
Member

Choose a reason for hiding this comment

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

optionnal => optional 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

That was an existing line ;)


const findTestResults = (testFiles, jestTestResults, jestTestFilesExt) =>
testFiles.map(name => {
[].concat(testFiles).map(name => {
Copy link
Contributor

Choose a reason for hiding this comment

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

why ? map() is immutable no ?

Copy link
Member Author

@tmeasday tmeasday May 30, 2018

Choose a reason for hiding this comment

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

[].concat() is a way to "ensure array" -- [].concat('a') ~== [].concat(['a'])

Copy link
Member Author

Choose a reason for hiding this comment

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

So it lets the user set { jest: 'filename' } or { jest: ['filename', 'other-filename'] } which is natural.

Copy link
Member

Choose a reason for hiding this comment

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

Array.from(testFiles) is a more explicit way to do the same

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I didn't know. Good trick.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Hypnosphi -- good one, I'll make that change.

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

chromatic snapshot failing?

@tmeasday
Copy link
Member Author

chromatic snapshot failing?

Arggh, looks like this bug has reared its head again.

@tmeasday
Copy link
Member Author

@renaudtertrais are you OK with the changed API/readme here?


const findTestResults = (testFiles, jestTestResults, jestTestFilesExt) =>
testFiles.map(name => {
[].concat(testFiles).map(name => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I didn't know. Good trick.

@tmeasday
Copy link
Member Author

@shilman I will look at the broken snapshot tomorrow but I don't think it is relevant to this branch, just flakiness on Chromatic's part wrt those iframe-based snapshots (as you saw on your own branch the other day).

},
] = args;

if (testFiles && !testFiles.skip) {
Copy link
Contributor

@Keraito Keraito Jun 12, 2018

Choose a reason for hiding this comment

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

Where does this testFiles.skip come from? Is this the same as the disable flag that we have in the other parameterized addons? It's not really documented anywhere.

Copy link
Contributor

@Keraito Keraito Jun 23, 2018

Choose a reason for hiding this comment

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

Poking @tmeasday just in case you missed this comment, since this is part of the 4.0 release. If you didn't, just ignore this message!

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @Keraito -- I have not forgotten, just getting around to this, sorry!

@tmeasday tmeasday merged commit 5f279c1 into master Jul 4, 2018
@tmeasday tmeasday deleted the tmeasday/refactor-jest-addon branch July 4, 2018 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants