Comments (19)
I've reproduced it on a fresh angular project. This happened when my addon calls the setStories
method of Storybook API. I'll try to fix it. Thank you for the report and your patience.
from creevey.
@BmsVisionJo I've just released the new version with the fix. Please, take a look.
from creevey.
I managed to achieve the desired result by setting our own globals instead of using the themes addon.
This now sets the classes correctly and by using your experimental gobals support we are now able to run the tests for different themes. Closing this issue now and will keep track of upcomming progress. Thank you.
from creevey.
This is strange. Creevey addon doesn't do anything with other addons. It just adds a panel in Storybook UI. I guess it could be related to this storybookjs/storybook#11442
About the waring, it's Storybook issue storybookjs/storybook#12872, try to update to 6.1.x
from creevey.
I've updated to Storybook 6.1.11 and that solved the warning, thanks for that.
I also updated to the newly released creevey 0.7.15.
Moving the order of the addons did not help. I have no issues however with my storybook untill I run the creevey command.
I switched on debug logging and saw this exception. Maybe this could be a problem?
info => Get angular-cli webpack config.
info => Using default Webpack setup
SyntaxError: Unexpected token, expected ";" (2:11)
at Object._raise (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:748:17)
at Object.raiseWithData (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:741:17)
at Object.raise (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:735:17)
at Object.unexpected (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:9101:16)
at Object.semicolon (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:9083:40)
at Object.parseExpressionStatement (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:12216:10)
at Object.parseExpressionStatement (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:6874:26)
at Object.parseStatementContent (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:11812:19)
at Object.parseStatementContent (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:6806:18)
at Object.parseStatement (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:11676:17)
at Object.parseBlockOrModuleBlockBody (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:12258:25)
at Object.parseBlockBody (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:12249:10)
at Object.parseBlock (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:12233:10)
at Object.parseStatementContent (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:11752:21)
at Object.parseStatementContent (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:6806:18)
at Object.parseStatement (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:11676:17) {
loc: Position { line: 2, column: 11 },
pos: 13
}
[CreeveyWorker]: Starting chrome:17740```
from creevey.
To clarify, you add creevey addon to the storybook config, then start storybook and open it in a browser. Your components are styled, even if you refresh the page. But, then you start creevey and refresh the page again styles disappear. If so, it's really strange, because the server doesn't affect storybook.
Do you have any errors in the browser console? Can also tell your angular version? I'll try to reproduce it.
from creevey.
No errors in the console, the angular version we are using is 10.1.5.
Happy to hear you can reproduce it. Thank you for looking into it.
from creevey.
About the exception in debug logging. Can you please send to me ([email protected]) a file from node_modules/creevey/node_modules/.cache/creevey/storybook/main.js
? I'll take a look and tell you where the problem is and how to fix it.
from creevey.
I've narrowed down the source of the exception leading me to the issue beeing babel trying to compile documentation.json thinking it is a javascript file and throwing an error that it needs a ";" character.
I've added logging to see where it fails and that shows me that the location of the error is at the "pipes" keyword that is in the documentation.json file.
{"type":"","start":6,"end":0,"loc":{"start":{"line":2,"column":4}},"expression":{"type":"StringLiteral","start":6,"end":13,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":11}},"extra":{"rawValue":"pipes","raw":"\"pipes\""},"value":"pipes"}}
SyntaxError: Unexpected token, expected ";" (2:11)
at Object._raise (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:748:17)
at Object.raiseWithData (C:\Users\jola\source\repos\Component Library\node_modules\creevey\node_modules\@babel\parser\lib\index.js:741:17)
Do you have any clue what could be wrong on our end? I Expect you got it working in that fresh angular project?
Could you provide us a functional project to compare maybe?
from creevey.
I think you mean this file. You can place these 3 lines into separate file and import it in the preview.js as workaround for now. I will fix it soon.
from creevey.
These lines were already there since we already used the docs addon.
from creevey.
I mean, your preview.js
file should be like this:
import './docs';
/* ... other stuff ... */
And in docs.js
you place
import { setCompodocJson } from "@storybook/addon-docs/angular";
import docJson from "../documentation.json";
setCompodocJson(docJson);
Actually, the compilation error you get in debugging is not a problem until Creevey loads and runs tests.
from creevey.
I've implemented the workarround and also installed creevey 0.7.18.
I am now able to refresh my page without losing the addon buttons wich is already a step forward.
The only issue remaining is that the taken images do not match with my storybook.
What could be causing this?
from creevey.
Oh, I see. If I'm right, you change a theme in the toolbar, and creevey captures the default one. Creevey doesn't sync any changes in the toolbar or controls. Because it could be a problem when you run creevey in CI, you can't switch between themes and capture just the default one.
I can suggest setting the default theme in parameters https://github.com/tonai/storybook-addon-themes#globally (the default
prop of the theme). But you will have been limited to capture only one theme. If you aren't ok with this, I have PR #104 that adds supporting globals.
from creevey.
We have a default theme:
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
themes: [
{ name: 'light touch', class: ['dx-swatch-light-theme', 'is-touch'], color: '#fff', default: true },
But next to that we also use some implementation to swap out css files based on the selected brand.
This is implemented the following way:
We have a preview-head.html file that sets a default brand from a dist folder.
<link id="cssBrand" rel="stylesheet" href="../dist/styles/bms.all.css">
Then we can change this href by using a decorator when clicking items in the toolbar.
const withBrandProvider=(storyFunc, globalTypes)=>{
const story = storyFunc();
const brand = globalTypes.globals.brand;
const linkCssBrand = document
.getElementById("cssBrand");
linkCssBrand.href = `../dist/styles/${brand}.all.css`;
return story;
}
export const decorators = [withBrandProvider];
We also have icons that are located in the dist folder and those do appear on the images, however the style doesnt.
Maybe the preview-head.html is not applied in the docker container?
I'm not able to look into it further as I have no experience debugging what is going on in that docker container.
from creevey.
What is globals.brand
default value?
The browser in docker container goes to the same storybook that you open in a browser. One exception is, it goes to http://localhost:6006/iframe.html?path=/story/{storyId}
, where {storyId}
is the id of the current story. You can open the story if you click on the second icon from the toolbar's top-left corner.
I guess creevey doesn't wait until new styles are loaded. Try to add creevey: { delay: 500 }
parameter in storybook parameters
from creevey.
I'm sorry I did not include that part.
export const globalTypes = {
brand: {
name: 'Brands',
description: 'Global brand',
defaultValue: 'bms',
toolbar: {
icon: 'circlehollow',
// array of plain string values or MenuItem shape (see below)
items: ['bms', 'savio'],
},
},
};
That may be a possible explanation, I will try it soon with the delay, thank you.
from creevey.
In later versions storybook has async loaders, you can try to add them, to check when styles loaded https://storybook.js.org/docs/react/writing-stories/loaders#global-loaders
from creevey.
@BmsVisionJo, I've just released new version with support globals, but it's experimental feature, and API will change.
from creevey.
Related Issues (20)
- Custom webpack loader not working HOT 2
- Behaviour of waitForReady and delay HOT 1
- Browser specific delays for tests HOT 3
- failFast:true disables maxRetries config option HOT 2
- Using webkit/safari results in ERROR => UnknownCommandError: Unknown command: /wd/hub/session HOT 1
- maxRetries and non-existing screenshots HOT 1
- Unexpected story export "image": expected function, received "object". HOT 2
- `ssh2` vulnerable version through `docker-modem` HOT 1
- [Creevey:21879] ERROR => TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined HOT 3
- Storybook vite builder breaks creevey chrome after hot-reload
- Storybook 6.4.0 - TypeError: Cannot read properties of undefined (reading 'removeAllListeners') HOT 12
- Creevey with Docker Desktop alternatives HOT 1
- Testing Firefox focus state issues HOT 1
- Malicious code through dependency
- Typescript support
- Storybook 6.5 support, bundle with many chunks
- creevey with storybook 6.5
- Extract `metadata` object from story
- Getting the creevey server can't reach error
- Does not support storybook 7 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from creevey.