Comments (9)
I found a workaround with https://www.npmjs.com/package/query-selector-shadow-dom
const showroom = require('showroom/puppeteer')();
const path = require('path');
describe('Calendar graph', async () => {
beforeAll(async () => {
await showroom.start();
await showroom.page.addScriptTag({
path: path.join(process.cwd(), 'node_modules/query-selector-shadow-dom/dist/querySelectorShadowDom.js')
})
});
beforeEach(async () => {
await showroom.utils.setTestSubject('calendar-graph');
});
afterAll(async ()=>{
await showroom.stop();
});
test('should show data', async () => {
await showroom.utils.trigger('initStatusMapping');
await showroom.utils.trigger('initData');
const foo = await showroom.page.evaluate(()=>querySelectorShadowDom.querySelectorAllDeep('calendar-graph .css-td').map(item=>item.innerText));
expect(foo).toBe(['hello', 'world']);
});
});
``
from showroom.
@msteller-connyun I'm glad you found a workaround. If I would add findAll with shadow path then the recursive search would be very laggy and might take too much time.
Showroom is meant for running unit-tests on a single-component level.
If you would like to add utils I would be happy for PRs or suggestions (via issues).
Happy testing.
P.S. I have started working on findAll with one major limitation: until the last '//' shadow path in the search it performs showroom.find
and then concatenates the rest of the query as querySelectorAll. Will branch this pretty soon.
from showroom.
I think your major limitation is fine for me, because I need findAll for unit testing data strucutres, like tables.
from showroom.
@msteller-connyun I would like to know what was your technique of injecting the deep-query script. Was it in the .showroom/config.js
file?
from showroom.
Hello @eavichay
I did it this way
beforeAll(async () => {
await showroom.start();
await loadLibs();
});
test('should show banner', async () => {
const expectedResult = ['no-display'];
await showroom.utils.trigger('init');
const result = await showroom.page.evaluate(() => [...querySelectorShadowDom.querySelectorDeep('cy-google-analytics .ga-banner').classList]);
expect(result).toEqual(expect.not.arrayContaining(expectedResult));
});
async function loadLibs() {
return new Promise(async (resolve) => {
await showroom.page.addScriptTag({
path: path.join(process.cwd(), 'node_modules/query-selector-shadow-dom/dist/querySelectorShadowDom.js')
});
resolve();
});
}
from showroom.
Awesome.
Basically any utils/scripts can be loaded using the config.js file. You can declare script sources that will be added as tags in the HTML.
I know there are yet undocumented features, but this eventually will be fully documented, perhaps with help from the community.
Thanks for the heads-up.
from showroom.
yeahh... but itβs still painful to use for the selectors an evaluate()
.
The load a third party library for the findAll is just a workaround.
from showroom.
π
from showroom.
So.. you closed that ticket. Does this mean there will be no native findAll support in showroom?
from showroom.
Related Issues (10)
- FF<66 Does not support `import()` HOT 1
- Missing dependency HOT 1
- Call a method? HOT 6
- The site doesn't work HOT 1
- Using internal properties editor strips down properties with function values HOT 1
- Documentation issues
- Bug: showroom.utils.trigger is fluffy HOT 10
- Need help with understanding Showroom HOT 8
- Render Container / Wrapper Overlay HOT 1
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 showroom.