-
Notifications
You must be signed in to change notification settings - Fork 54
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
Run specs with Jest outside of storybook or all tests in storybook #17
Comments
I'm not sure ton understand what you mean by you need to use different files . Also can you explicit more what you mean by this: "execute all storybook tests in terminal". Currently this plugin allow you to display tests results as specs in storybook (tests are played each time you see a storybook page, but only those concerned by the story). You can also use the .stories.js file directly within you test runner to avoid rewriting your test and to have a proper ci. Did you try to follow the tutorial in the readme with the creation of the facade? Do you have some concrete issue that you encounter? |
I believe the problem is a similar one I'm having. File structure:
/ App.stories.js storiesOf('App', module)
.add('with greeting', () => {
const greeting = 'Hello'
const story = <App greeting={greeting} />
specs(() => require('./App.test').tests) // run tests from separate file
return story
}) / App.test.js import React from 'react'
import ReactDOM from 'react-dom'
import App from './index'
import { mount } from 'enzyme'
// tests are loaded in React Storybook
export const tests = describe('App', () => {
it('Should have the Hello World label', () => {
const output = mount(<App greeting="Hello" />)
expect(output.text()).toContain('World!')
})
}) I can get my tests to run with Jest, or I can get my tests to run with React Storybook, but can't seem to have my cake and eat it too. StoryBook FailsThe Storybook error has to do with Jest FailsIf I set / App.test.js describe = describe || require('storybook-addon-specifications').describe
it = it || require('storybook-addon-specifications').it Facade.jsPerhaps my "facade.js" file is not working. If that is the case, how can I verify it's failure? |
Finally worked out a solution. See the code in this boilerplate repo I put together. Tests now load in Jest & React Storybook, while maintaining the tests in a different file. SolutionConfigure the Storybook test settings on startup using globals. /.storybook/test.js import { describe, it } from 'storybook-addon-specifications'
import expect from 'expect'
window.describe = describe
window.it = it
window.expect = expect /.storybook/config.js /* imports */
import './test'
/* config */ Import the tests so that they are loaded on startup. Do not use "require". /components/App.stories.js import { tests } from './App.test'
storiesOf('App', module)
.add('with greeting', () => {
const greeting = 'Hello'
const story = <App greeting={greeting} />
specs(() => tests)
return story
}) |
Oh ok, you wanted to go in the opposite direction of what I have in mind while creating this addon. That's nice if you manage to make it work. Question: the tests you pass to the story actually aren't using the story itself but use another component declaration. That means that you'll need to maintain this declaration synchronized in time. Maybe those two could be merged? |
@ShMcK I Have come up with a pretty much identical solution. /.storybook/config.js import './test-register' /.storybook/test-register.js const {
after: afterAll,
before: beforeAll,
afterEach,
beforeEach,
it,
specs,
describe
} = require('storybook-addon-specifications');
const expect = require('expect');
const additions = { expect, afterAll, afterEach, beforeAll, beforeEach, it, specs, describe };
Object.assign(global, additions);
module.exports = additions; I feel like the import in |
I'm looking into being able to nest describes in tests: describe('Component Name', () => {
describe('section 1', () => {
it('should be awesome', () => {
const output = mount(<Component/>);
expect(output.text()).toContain('Awesome');
});
});
}); Currently this will display nothing in the specifications tab. |
@ndelangen can you open another issue describe this behavior please? |
@ndelangen, @ShMcK : maybe you could add en entry on the readme explaining how to include external tests inside storybook? |
I'll describe the setup that worked for me in a markdown doc, and submit a PR. Do you want me to add it to Readme.md ? because it's already quite big as it is? @mthuret |
Added a README pull request explaining how to setup external tests. #19 |
@ndelangen @ShMcK In the docs for having tests in external file, what are the pros/cons for doing this? In the following code example, there was no mention of installing
Thank you. |
It's been a little while since I've used react storybook in production, but last time I was working on this, I had come to this conclusion: What I want is my full jest test-suite to run, then start watching. The results (json) should be recorded, and pushed to storybook. And when in watch / dev -mode, when jest has detected a change, and run on the changed files, the new bit of json should be pushed to storybook. Probably over a websocket. With the recent addition of server-middleware to storybook this is possible. I've written a POC jest observer: https://github.com/ndelangen/jest-observer that captures jest's output-json, only to discover this is totally unnecessary if I'd utilize node-ipc. But perhaps the observer could be a nice abstraction for this, I don't know. Anyway, the json would need to be rendered into some UI in storybook, and possibly be split and matched up with the right story.. All of this because: jest does not run in a browser. I've tried getting it to run in a browser environment, but I've had no luck so far. By moving the test into their own file, they seem to be normal jest test files, unrelated to storybook. But they can't be full jest test-files, because it's not actually jest running in the browser, so only a subset of the jest api is available. Once I've got time / use storybook in production again, I'll probably finish this tooling. Sorry for the side-track, What you're asking is the cons of placing the tests in a separate file: Don't be fooled it's jest running in the browser and understand it's a subset of jest's features at your disposal. Regarding chai, seems like that should work just fine. |
I need to have a look at this server-middleware new feature of storybook. As you said @ndelangen you can not use every jest features with the specs addons as it will not run in the browser. So basically as long as you test pure UI component with enzyme you're fine, but as soon as you have connected one or IO to mock, you're stucked. You can still use the old way to test your stories by importing them directly in a jest file, but you will not have any specs displayed on the storybook, which is a loss. |
One thing that could be nice for a v2 of the specs addons is:
There's one thing I don't know how to handle yet. Basically what I'm trying to have is: FeatureA.stories.js storiesOf('RefinementList'); FeatureA.test.js describe('RefinementList') But the problem with that is that the jest json output doesn't handle the describe hierarchy, everything is flatten under one filename. |
Thanks I wasn't aware of that, the streaming test results to storybook sounds great and means they run in Node. |
@mthuret I haven't taken a deep look into the jest output json, but that would indeed make it hard to make it do what you want. How bad would it be to show all unit test off all stories? aka show all test in the file? |
Well I assume you could have variation depending on the props, so you would end up with some tests that are not directly related to the current story. But maybe this first step is a good start :) |
Yeah that's what I was thinking, and maybe jest actually has a way of getting more verbose json? Or we could request/suggest such a feature. Seems necessary if someone would want to write a true GUI for jest. |
I was thinking of creating a new |
https://facebook.github.io/jest/docs/configuration.html#testresultsprocessor-string Here's a little experiment I did with that: |
So I worked on this feature this week-end and you can see a preview of it on this branch: https://github.com/mthuret/storybook-addon-specifications/tree/jest-test-files If you want to see it live, just run the storybook and go to the HelloWorld stories. It will run tests through jest on the server. I'm not sure I should use the jest-cli like I do, but it works. @ndelangen what do you think about it? |
Took a super-quick look, and think this could work. But can I suggest something? Right now it looks like switching stories makes an api call, then have jest run tests, send the results and then render them in storybook. Is this correct? What we can do is run jest on all files on start, and send the entire result to storybook. Of course we want to show the right test-results, even if source- or test-files change. It would mean adding websocket support in the middleware, and connecting to the websocket in the plugin. Next we could try and connecting to an existing jest instance in watchmode, or spin up our own. What do you think? Concerning static publishing, in order to make this possible we need to generate jest output in advance. This means hooking into the storybook build-script. I'm not sure that has been done before? But could be another feature to add to storybook if not already possible. I'm happy to help you build this btw, need to find time. 🤞🏻 |
Thanks for the feedback @ndelangen. I really like your proposal even if it's require more work :) Also I will be more than happy if you help me build this, as I think it could really solve a lot of issues that exists today. |
I did a dive into the json jest output's and it actually has all the data we need. The trick is: it's layered by describes: jest.runCLI({watchAll: false, verbose: true}, getPackageRoot(), (result) => {
fs.writeFile('./result.json', JSON.stringify(result, null, 2) , 'utf-8');
}); will output: {
"numFailedTestSuites": 2,
"numFailedTests": 3,
"numPassedTestSuites": 1,
"numPassedTests": 6,
"numPendingTestSuites": 0,
"numPendingTests": 0,
"numRuntimeErrorTestSuites": 0,
"numTotalTestSuites": 3,
"numTotalTests": 9,
"snapshot": {
"added": 0,
"failure": false,
"filesAdded": 0,
"filesRemoved": 0,
"filesUnmatched": 0,
"filesUpdated": 0,
"matched": 2,
"total": 2,
"unchecked": 0,
"unmatched": 0,
"updated": 0
},
"startTime": 1488870837491,
"success": false,
"testResults": [
{
"console": null,
"failureMessage": null,
"numFailingTests": 0,
"numPassingTests": 5,
"numPendingTests": 0,
"perfStats": {
"end": 1488870839114,
"start": 1488870838543
},
"snapshot": {
"added": 0,
"fileDeleted": false,
"matched": 2,
"unchecked": 0,
"unmatched": 0,
"updated": 0
},
"testFilePath": "/Users/dev/Projects/Playground/storybook-addon-specifications/.storybook/__tests__/sample.ci.jest.stories.js",
"testResults": [
{
"ancestorTitles": [
"Hello World"
],
"duration": 18,
"failureMessages": [],
"fullName": "Hello World Should have the Hello World label",
"numPassingAsserts": 0,
"status": "passed",
"title": "Should have the Hello World label"
},
{
"ancestorTitles": [
"Hello World"
],
"duration": 3,
"failureMessages": [],
"fullName": "Hello World Should have the Hello World label",
"numPassingAsserts": 0,
"status": "passed",
"title": "Should have the Hello World label"
},
{
"ancestorTitles": [],
"duration": 33,
"failureMessages": [],
"fullName": "test Hello World",
"numPassingAsserts": 0,
"status": "passed",
"title": "Hello World"
},
{
"ancestorTitles": [
"Hello Earth"
],
"duration": 1,
"failureMessages": [],
"fullName": "Hello Earth Should have the Hello Earth label",
"numPassingAsserts": 0,
"status": "passed",
"title": "Should have the Hello Earth label"
},
{
"ancestorTitles": [],
"duration": 0,
"failureMessages": [],
"fullName": "test Hello Earth",
"numPassingAsserts": 0,
"status": "passed",
"title": "Hello Earth"
}
],
"skipped": false
},
{
"console": null,
"failureMessage": "\u001b[1m\u001b[31m \u001b[1m● \u001b[1mHelloWorld › story1 › Should have the Hello World label\u001b[39m\u001b[22m\n\n Expected 1 to be 2\n\u001b[2m \n \u001b[2mat assert (\u001b[2mnode_modules/expect/lib/assert.js\u001b[2m:29:9)\u001b[2m\n \u001b[2mat Expectation.toBe (\u001b[2mnode_modules/expect/lib/Expectation.js\u001b[2m:66:28)\u001b[2m\n \u001b[2mat Object.<anonymous> (\u001b[2m\u001b[0m\u001b[36m.storybook/__tests__/HelloWorld.ci.jest.stories.js\u001b[39m\u001b[0m\u001b[2m:13:58)\u001b[2m\n \u001b[2mat handle (\u001b[2mnode_modules/worker-farm/lib/child/index.js\u001b[2m:41:8)\u001b[2m\n \u001b[2mat process.<anonymous> (\u001b[2mnode_modules/worker-farm/lib/child/index.js\u001b[2m:47:3)\u001b[2m\n \u001b[2mat emitTwo (\u001b[2mevents.js\u001b[2m:106:13)\u001b[2m\n \u001b[2mat process.emit (\u001b[2mevents.js\u001b[2m:191:7)\u001b[2m\n \u001b[2mat process.nextTick (\u001b[2minternal/child_process.js\u001b[2m:744:12)\u001b[2m\n \u001b[2mat _combinedTickCallback (\u001b[2minternal/process/next_tick.js\u001b[2m:67:7)\u001b[2m\n \u001b[2mat process._tickCallback (\u001b[2minternal/process/next_tick.js\u001b[2m:98:9)\u001b[2m\u001b[22m\n\n\u001b[1m\u001b[31m \u001b[1m● \u001b[1mHelloWorld › story2 › Should have the Hello World label\u001b[39m\u001b[22m\n\n Expected 'Hello World' to include 'Spec1'\n\u001b[2m \n \u001b[2mat assert (\u001b[2mnode_modules/expect/lib/assert.js\u001b[2m:29:9)\u001b[2m\n \u001b[2mat Expectation.toInclude (\u001b[2mnode_modules/expect/lib/Expectation.js\u001b[2m:215:28)\u001b[2m\n \u001b[2mat Object.<anonymous> (\u001b[2m\u001b[0m\u001b[36m.storybook/__tests__/HelloWorld.ci.jest.stories.js\u001b[39m\u001b[0m\u001b[2m:19:70)\u001b[2m\n \u001b[2mat handle (\u001b[2mnode_modules/worker-farm/lib/child/index.js\u001b[2m:41:8)\u001b[2m\n \u001b[2mat process.<anonymous> (\u001b[2mnode_modules/worker-farm/lib/child/index.js\u001b[2m:47:3)\u001b[2m\n \u001b[2mat emitTwo (\u001b[2mevents.js\u001b[2m:106:13)\u001b[2m\n \u001b[2mat process.emit (\u001b[2mevents.js\u001b[2m:191:7)\u001b[2m\n \u001b[2mat process.nextTick (\u001b[2minternal/child_process.js\u001b[2m:744:12)\u001b[2m\n \u001b[2mat _combinedTickCallback (\u001b[2minternal/process/next_tick.js\u001b[2m:67:7)\u001b[2m\n \u001b[2mat process._tickCallback (\u001b[2minternal/process/next_tick.js\u001b[2m:98:9)\u001b[2m\u001b[22m\n",
"numFailingTests": 2,
"numPassingTests": 0,
"numPendingTests": 0,
"perfStats": {
"end": 1488870839487,
"start": 1488870838541
},
"snapshot": {
"added": 0,
"fileDeleted": false,
"matched": 0,
"unchecked": 0,
"unmatched": 0,
"updated": 0
},
"testFilePath": "/Users/dev/Projects/Playground/storybook-addon-specifications/.storybook/__tests__/HelloWorld.ci.jest.stories.js",
"testResults": [
{
"ancestorTitles": [
"HelloWorld",
"story1"
],
"duration": 18,
"failureMessages": [
"Error: Expected 1 to be 2\n at assert (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/expect/lib/assert.js:29:9)\n at Expectation.toBe (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/expect/lib/Expectation.js:66:28)\n at Object.<anonymous> (/Users/dev/Projects/Playground/storybook-addon-specifications/.storybook/__tests__/HelloWorld.ci.jest.stories.js:13:58)\n at Object.<anonymous> (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/build/jasmine-async.js:42:32)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1968:16\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1911:9\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/build/jasmine-async.js:68:11)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at QueueRunner.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1929:10)\n at Spec.queueRunnerFactory (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:718:35)\n at Spec.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:372:10)\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2586:37)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at QueueRunner.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1929:10)\n at queueRunnerFactory (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:718:35)\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2571:13)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at QueueRunner.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1929:10)\n at queueRunnerFactory (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:718:35)\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2571:13)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at QueueRunner.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1929:10)\n at queueRunnerFactory (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:718:35)\n at TreeProcessor.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2433:7)\n at Env.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:780:17)\n at jasmine2 (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/build/index.js:93:7)\n at runTest (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-cli/build/runTest.js:53:10)\n at module.exports.error (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-cli/build/TestWorker.js:62:5)\n at handle (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/worker-farm/lib/child/index.js:41:8)\n at process.<anonymous> (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/worker-farm/lib/child/index.js:47:3)\n at emitTwo (events.js:106:13)\n at process.emit (events.js:191:7)\n at process.nextTick (internal/child_process.js:744:12)\n at _combinedTickCallback (internal/process/next_tick.js:67:7)\n at process._tickCallback (internal/process/next_tick.js:98:9)"
],
"fullName": "HelloWorld story1 Should have the Hello World label",
"numPassingAsserts": 0,
"status": "failed",
"title": "Should have the Hello World label"
},
{
"ancestorTitles": [
"HelloWorld",
"story2"
],
"duration": 3,
"failureMessages": [
"Error: Expected 'Hello World' to include 'Spec1'\n at assert (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/expect/lib/assert.js:29:9)\n at Expectation.toInclude (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/expect/lib/Expectation.js:215:28)\n at Object.<anonymous> (/Users/dev/Projects/Playground/storybook-addon-specifications/.storybook/__tests__/HelloWorld.ci.jest.stories.js:19:70)\n at Object.<anonymous> (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/build/jasmine-async.js:42:32)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1968:16\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1911:9\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/build/jasmine-async.js:68:11)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at QueueRunner.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1929:10)\n at Spec.queueRunnerFactory (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:718:35)\n at Spec.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:372:10)\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2586:37)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at QueueRunner.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1929:10)\n at queueRunnerFactory (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:718:35)\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2571:13)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1968:16\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1911:9\n at onComplete (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2574:17)\n at QueueRunner.clearStack (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:681:9)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1951:12)\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1968:16\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1911:9\n at complete (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:384:9)\n at QueueRunner.clearStack (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:681:9)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1951:12)\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1968:16\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1911:9\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1989:9)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1968:16\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1911:9\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/build/jasmine-async.js:68:11)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at QueueRunner.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1929:10)\n at Spec.queueRunnerFactory (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:718:35)\n at Spec.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:372:10)\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2586:37)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at QueueRunner.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1929:10)\n at queueRunnerFactory (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:718:35)\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2571:13)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at QueueRunner.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1929:10)\n at queueRunnerFactory (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:718:35)\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2571:13)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at QueueRunner.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1929:10)\n at queueRunnerFactory (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:718:35)\n at TreeProcessor.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2433:7)\n at Env.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:780:17)\n at jasmine2 (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/build/index.js:93:7)\n at runTest (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-cli/build/runTest.js:53:10)\n at module.exports.error (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-cli/build/TestWorker.js:62:5)\n at handle (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/worker-farm/lib/child/index.js:41:8)\n at process.<anonymous> (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/worker-farm/lib/child/index.js:47:3)\n at emitTwo (events.js:106:13)\n at process.emit (events.js:191:7)\n at process.nextTick (internal/child_process.js:744:12)\n at _combinedTickCallback (internal/process/next_tick.js:67:7)\n at process._tickCallback (internal/process/next_tick.js:98:9)"
],
"fullName": "HelloWorld story2 Should have the Hello World label",
"numPassingAsserts": 0,
"status": "failed",
"title": "Should have the Hello World label"
}
],
"skipped": false
},
{
"console": null,
"failureMessage": "\u001b[1m\u001b[31m \u001b[1m● \u001b[1mHelloWorld › story2 › Should have the Hello World label\u001b[39m\u001b[22m\n\n Expected 'Hello World' to include 'Spec1'\n\u001b[2m \n \u001b[2mat assert (\u001b[2mnode_modules/expect/lib/assert.js\u001b[2m:29:9)\u001b[2m\n \u001b[2mat Expectation.toInclude (\u001b[2mnode_modules/expect/lib/Expectation.js\u001b[2m:215:28)\u001b[2m\n \u001b[2mat Object.<anonymous> (\u001b[2m\u001b[0m\u001b[36m.storybook/__tests__/HelloWorldBoup.ci.jest.stories.js\u001b[39m\u001b[0m\u001b[2m:18:70)\u001b[2m\n \u001b[2mat handle (\u001b[2mnode_modules/worker-farm/lib/child/index.js\u001b[2m:41:8)\u001b[2m\n \u001b[2mat process.<anonymous> (\u001b[2mnode_modules/worker-farm/lib/child/index.js\u001b[2m:47:3)\u001b[2m\n \u001b[2mat emitTwo (\u001b[2mevents.js\u001b[2m:106:13)\u001b[2m\n \u001b[2mat process.emit (\u001b[2mevents.js\u001b[2m:191:7)\u001b[2m\n \u001b[2mat process.nextTick (\u001b[2minternal/child_process.js\u001b[2m:744:12)\u001b[2m\n \u001b[2mat _combinedTickCallback (\u001b[2minternal/process/next_tick.js\u001b[2m:67:7)\u001b[2m\n \u001b[2mat process._tickCallback (\u001b[2minternal/process/next_tick.js\u001b[2m:98:9)\u001b[2m\u001b[22m\n",
"numFailingTests": 1,
"numPassingTests": 1,
"numPendingTests": 0,
"perfStats": {
"end": 1488870839523,
"start": 1488870838572
},
"snapshot": {
"added": 0,
"fileDeleted": false,
"matched": 0,
"unchecked": 0,
"unmatched": 0,
"updated": 0
},
"testFilePath": "/Users/dev/Projects/Playground/storybook-addon-specifications/.storybook/__tests__/HelloWorldBoup.ci.jest.stories.js",
"testResults": [
{
"ancestorTitles": [
"HelloWorld",
"story1"
],
"duration": 19,
"failureMessages": [],
"fullName": "HelloWorld story1 Should have the Hello World label",
"numPassingAsserts": 0,
"status": "passed",
"title": "Should have the Hello World label"
},
{
"ancestorTitles": [
"HelloWorld",
"story2"
],
"duration": 3,
"failureMessages": [
"Error: Expected 'Hello World' to include 'Spec1'\n at assert (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/expect/lib/assert.js:29:9)\n at Expectation.toInclude (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/expect/lib/Expectation.js:215:28)\n at Object.<anonymous> (/Users/dev/Projects/Playground/storybook-addon-specifications/.storybook/__tests__/HelloWorldBoup.ci.jest.stories.js:18:70)\n at Object.<anonymous> (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/build/jasmine-async.js:42:32)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1968:16\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1911:9\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/build/jasmine-async.js:68:11)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at QueueRunner.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1929:10)\n at Spec.queueRunnerFactory (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:718:35)\n at Spec.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:372:10)\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2586:37)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at QueueRunner.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1929:10)\n at queueRunnerFactory (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:718:35)\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2571:13)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1968:16\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1911:9\n at onComplete (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2574:17)\n at QueueRunner.clearStack (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:681:9)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1951:12)\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1968:16\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1911:9\n at complete (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:384:9)\n at QueueRunner.clearStack (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:681:9)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1951:12)\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1968:16\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1911:9\n at Object.<anonymous> (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/build/jasmine-async.js:47:11)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1968:16\n at /Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1911:9\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/build/jasmine-async.js:68:11)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at QueueRunner.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1929:10)\n at Spec.queueRunnerFactory (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:718:35)\n at Spec.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:372:10)\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2586:37)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at QueueRunner.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1929:10)\n at queueRunnerFactory (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:718:35)\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2571:13)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at QueueRunner.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1929:10)\n at queueRunnerFactory (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:718:35)\n at Object.fn (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2571:13)\n at attemptAsync (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1986:24)\n at QueueRunner.run (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1941:9)\n at QueueRunner.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1929:10)\n at queueRunnerFactory (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:718:35)\n at TreeProcessor.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:2433:7)\n at Env.execute (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:780:17)\n at jasmine2 (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-jasmine2/build/index.js:93:7)\n at runTest (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-cli/build/runTest.js:53:10)\n at module.exports.error (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/jest-cli/build/TestWorker.js:62:5)\n at handle (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/worker-farm/lib/child/index.js:41:8)\n at process.<anonymous> (/Users/dev/Projects/Playground/storybook-addon-specifications/node_modules/worker-farm/lib/child/index.js:47:3)\n at emitTwo (events.js:106:13)\n at process.emit (events.js:191:7)\n at process.nextTick (internal/child_process.js:744:12)\n at _combinedTickCallback (internal/process/next_tick.js:67:7)\n at process._tickCallback (internal/process/next_tick.js:98:9)"
],
"fullName": "HelloWorld story2 Should have the Hello World label",
"numPassingAsserts": 0,
"status": "failed",
"title": "Should have the Hello World label"
}
],
"skipped": false
}
],
"wasInterrupted": false
}
|
Made a tiny bit progress today: |
@ndelangen that's super nice o/ |
I added websockets to the POC 💯 ! |
Let me know if you want to have this as a PR or share access to the fork/branch if you feel like working on this together? |
Created a WIP PR #32 |
I'd really like to get my Jest tests running in a terminal while the specs also run in the Storybook. This tool is amazing, makes TDD super easy to do. |
2019 is calling and is curious what happened? :) |
I made this (demo repo), which I feel is a pretty 'clean' way of getting things working in both... there might be some redundant rubbish in there as I pulled it from my project but maybe it helps someone 🤷♂ https://github.com/GastroGeek/storybook-vue-specs-jest-testing |
I'm using Jest as my test runner, and I've noticed that at times I want to run the same tests from both with storybook (with the spec addon) and outside of it (with just the Jest command in the terminal), but I'm running into issues making this work. I can create independent functions and then import those functions into separate files - a comp.test.js and a comp.stories.js and execute those files with Jest and Storybook respectively, and that works, but I would love a little cleaner solution, like "execute all storybook tests in terminal". Any ideas?
The text was updated successfully, but these errors were encountered: