capricorn86 / jest-environment-happy-dom Goto Github PK
View Code? Open in Web Editor NEWAn alternative to jsdom with support for web components.
License: MIT License
An alternative to jsdom with support for web components.
License: MIT License
Hello!
First of all, thank you for the work and effort in creating happy dom & happy dom jest environment - it's nice to see community support for LitElement environment :)
I have been trying to make a simple proof of concept test to mess with the library/environment and check how it works, but I'm not able to create my custom element inside test - I always got an error running them regarding TypeError: Cannot read property 'forEach' of undefined.
const element = document.createElement('sample-component');
const myContainer = document.querySelector('body');
myContainer.appendChild(element);
This is the stack trace:
126 | /**
127 | * @license
128 | * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
at t.forEach [as **_saveInstanceProperties**] (dist/main.js:125:4431)
at t._saveInstanceProperties (dist/main.js:125:4323)
at t.initialize (dist/main.js:139:581)
at t.initialize (dist/main.js:125:2584)
at t.ye (dist/main.js:3:2239)
at new call (dist/main.js:139:2704)
at createElement (__tests__/sample-component.test.js:14:30)
I have also needed to polyfill window.requestAnimationFrame and window.performance, otherwise I couldn't even run the tests but seems strange for me - it's necessary?
I have confirmed my bundled build works as expected after testing standalone on browser (it's just a simple custom element definition).
Inside the test spec file, I have also another test checking if the custom element has been defined, and it works as expected, so it sounds strange for me :/ Do it sounds familiar to you???
Thanks for all!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.