-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Storybook addon Jest angular suport #3532
Conversation
cc @igor-dv |
examples/angular-cli/package.json
Outdated
@@ -28,6 +32,7 @@ | |||
"@angular/cli": "1.7.4", | |||
"@angular/compiler-cli": "^5.2.10", | |||
"@storybook/addon-actions": "4.0.0-alpha.4", | |||
"@storybook/addon-jest": "^3.4.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.
please update to the 4.0.0-alpha (and bootstrap again, because lock file is wrong 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.
fixed)
Codecov Report
@@ Coverage Diff @@
## master #3532 +/- ##
======================================
Coverage 92.5% 92.5%
======================================
Files 6 6
Lines 40 40
Branches 2 2
======================================
Hits 37 37
Misses 2 2
Partials 1 1 Continue to review full report at Codecov.
|
addons/jest/README.md
Outdated
|
||
Assuming that you have created a test files `my.component.spec.ts` and `my-other.comonent.spec.ts` | ||
|
||
Config Jest with [jest-preset-angular](https://www.npmjs.com/package/jest-preset-angular) |
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.
*Configure
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.
done
addons/jest/README.md
Outdated
|
||
Config Jest with [jest-preset-angular](https://www.npmjs.com/package/jest-preset-angular) | ||
|
||
In project `typings.d.ts` add |
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.
*In project's typings.d.ts
add
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.
done
addons/jest/README.md
Outdated
|
||
storiesOf('MyComponent', module) | ||
.addDecorator(wTests('my.component', 'my-other.component')) | ||
.add('This story shows test results from MyComponent.test.js and MyOtherComponent.test.js', () => ( |
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.
my.component.spec.ts
, my-other.comonent.spec.ts
?
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.
Need only name.
Extension added in withTests.ts
In addons\jest\src\index.js
it look like
new RegExp(`${name}${jestTestFilesExt}`).test(t.name)
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 mean, you wrote above
Assuming that you have created a test files
my.component.spec.ts
andmy-other.comonent.spec.ts
So I think it's better to have the same naming
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.
done
@@ -0,0 +1 @@ | |||
{"numFailedTestSuites":0,"numFailedTests":0,"numPassedTestSuites":1,"numPassedTests":3,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTotalTestSuites":1,"numTotalTests":3,"snapshot":{"added":0,"didUpdate":false,"failure":false,"filesAdded":0,"filesRemoved":0,"filesUnmatched":0,"filesUpdated":0,"matched":0,"total":0,"unchecked":0,"uncheckedKeys":[],"unmatched":0,"updated":0},"startTime":1525561826280,"success":true,"testResults":[{"assertionResults":[{"ancestorTitles":["AppComponent"],"failureMessages":[],"fullName":"AppComponent should create the app","location":null,"status":"passed","title":"should create the app"},{"ancestorTitles":["AppComponent"],"failureMessages":[],"fullName":"AppComponent should have as title 'app'","location":null,"status":"passed","title":"should have as title 'app'"},{"ancestorTitles":["AppComponent"],"failureMessages":[],"fullName":"AppComponent should render title in a h1 tag","location":null,"status":"passed","title":"should render title in a h1 tag"}],"endTime":1525561829266,"message":"","name":"/home/kliment/Projects/storybook/examples/angular-cli/src/app/app.component.spec.ts","startTime":1525561827019,"status":"passed","summary":""}],"wasInterrupted":false} |
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 this be gitignored?
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.
circleci tests are crash when ignore .jest-test-results.json
because the file was not found
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.
But it should be generated on a build command, shouldn't it?
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.
it`s work in angular-cli application and generate output for angular-cli application.
yarn test --core
run before build and crash
Summary of all failing tests
FAIL examples/angular-cli/angularshots.test.js
● Test suite failed to run
Cannot find module '../.jest-test-results.json' from 'withTests.ts'
How can i fix it? Maybe write separate task for angular in scripts/test.js
? How can i run it before yarn test --core
?
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.
Maybe leave .jest-test-results.json
in this example project?
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.
fixed. .jest-test-results.json
removed and test crashed.
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.
Let's commit then. Just checked we have a similar file for the React example, so it's ok. Let's just call it "addon-jest.testresults.json" for the convention.
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.
done
released as |
What I did