-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
How to access getStoryBook in Node? (Storybook 3.0.1) #1208
Comments
I'm going to be visual diff'ing using StoryBook soon too, but I wont be access the node api, just the This is good enough for me for now, as you can set up each story individually.
|
@peter-mouland But how would you "extract" all components and stories so you know which url's to test? Or will you be hardcoding all urls? |
@heinzmuller |
good point - for now i'm hard coding as I've only got a few. It sounds a little left field for the main project, but maybe we need to create a plugin like |
Percy and Screener are doing. I think both based on the code Storyshots uses: |
This produces better screenshots than loading the Storybook UI. Discovered while researching possiblity of using Storybook API to discover test names: storybookjs/storybook#1208
* DP-10134 make Backstop discover all stories, update images * Re-enable eslint for backstop/, fix lint issues. * Group local imports * DP-10134 minor tweak to storybook URL This produces better screenshots than loading the Storybook UI. Discovered while researching possiblity of using Storybook API to discover test names: storybookjs/storybook#1208 * DP-10134 use path.resolve, remove unneeded backstop url params * Removes the need to have seperate commands for atoms and other components. * Updated visual regression documentation. * Updated comments.
if anyone else ends up coming back here (years later) then there is a quick and simple solution. The reason I was interested in a node-api (more recently) is because storybook takes an age to start (300+ components). Luckily for me, in CI, we've already built storybook (to publish demos per feature branch). This means that we can run a simple static server + anything in the My functional tests can then point to this server (via Cypress etc) and load pages using the iframe mentioned earlier (http://localhost:9001/iframe.html?selectedKind=COMPONENT_NAME&selectedStory=STORY NAME) // spa.js
const path = require('path');
const express = require('express');
const mockApiMiddleware = require('./middleware');
const app = express();
const router = express.Router();
mockApiMiddleware(router);
app.use('/', express.static(path.join(__dirname, 'out')));
app.use('/', router);
const runner = ({ port = 9001 } = {}) =>
new Promise((resolve) => {
const server = app.listen(port, () => {
console.log(`app listening on port ${port}!`);
resolve(server);
});
});
if (require.main === module) {
runner();
} else {
module.exports = { runner };
} for completeness /* eslint-disable no-console */
const cypress = require('cypress');
const { argv } = require('yargs');
const { runner } = require('../.storybook/spa');
const { browser = 'electron', debug = false, host = 'localhost', dev = false } = argv;
const PORT = process.env.port || process.env.PORT || '3021';
const timeout = 2000;
const testFiles = '**/*.func.js';
const config = {
baseUrl: `http://localhost:${PORT}`,
integrationFolder: 'scopes',
testFiles,
reporter: 'junit',
reporterOptions: {
mochaFile: 'cypress/results/test-results.xml',
toConsole: true,
},
chromeWebSecurity: false,
};
const cypressConfig = {
spec: `scopes/**`,
reporter: 'junit',
browser,
config,
env: {},
};
const beginTester = () => cypress[debug ? 'open' : 'run'](cypressConfig);
if (dev) {
console.log(`Please ensure you already have storybook running\n * yarn storybook`);
beginTester();
} else {
console.log(`Please ensure you have built storybook\n * yarn storybook:build`);
runner({ port: PORT }).then((server) => {
beginTester().then((results) => {
server.close();
const exitCode = results.totalFailed > 0 ? 1 : 0;
process.exit(exitCode);
});
});
} |
Hello
I am trying to add visual diffing using PhantomCSS. I see that there is an open issue #26.
To integrate with Casper, I need to get all the StoryKinds and associated stories (at least the labels if not the actual methods).
My question is how to execute the getStoryBook() method in '@storybook/react' so I can integrate with Casper. Is there any sample code/ config which will do the same?
Btw, I am using https://github.com/storybooks/storybook/releases/tag/v3.0.1
Thanks
RV
The text was updated successfully, but these errors were encountered: