-
Notifications
You must be signed in to change notification settings - Fork 201
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
[wct headless] tests failing when using import #567
Comments
Interesting usage. While
Notice the inclusion of Then you can get this called from
This will have you up and running until someone can decide whether direct support of modules in |
Great, thanks so much for the reply and advice. Will give this a try! |
Just my $.02 re: the use of I was also seeing similar developer experiences with @skatejs/ssr. Taking this very simple example, It would be pretty neat (IMHO) to be able to do something similar when using hello-component.jsclass HelloComponent extends HTMLElement {
constructor() {
super();
this.root = this.attachShadow({ mode: 'closed' });
this.root.innerHTML = this.template();
}
template() {
return `
<h3>Hello World!<h3>
`;
}
}
customElements.define('x-hello', HelloComponent); hello-component.spec.jsimport './hello.component.js';
import { mount } from '@skatejs/bore'; // or whatever DOM testing library you like
describe('HelloComponent', () => {
let component;
beforeEach(() => {
component = mount('<x-hello></x-hello>');
})
it('should render Hello World', () => {
expect(component.innerHTML).toBe('Hello World!');
});
it('should have an <h3> element', () => {
expect(component.find('h3').length).toBe(1);
});
}); |
Thanks for your help @Westbrook , I got it working and was able to keep the specs in JavaScript (albeit without index.html<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="../node_modules/wct-browser-legacy/browser.js"></script>
<script src="../node_modules/@polymer/test-fixture/test-fixture-mocha.js"></script>
<script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
<script type="module" src="../src/index.js"></script>
<test-fixture id="hello">
<template>
<eve-hello></eve-hello>
</template>
</test-fixture>
<script>
WCT.loadSuites([
'./hello-world.spec.js'
]);
</script>
</head>
</html> hello-world.spec.jsdescribe('HelloComponent', function() {
let componentRoot;
beforeEach(() => {
componentRoot = fixture('hello').root;
});
describe('heading', () => {
let heading;
beforeEach(() => {
heading = componentRoot.querySelectorAll('h3.heading');
});
it('should have one heading element', () => {
expect(heading.length).to.equal(1);
});
it('should say Hello World!', () => {
expect(heading[0].innerHTML).to.equal('Hello World!');
});
});
}); Thanks for your help!! Native |
Documented my efforts so far with WCT. Thanks for your help! |
Hello! 👋
I've been looking at Web Component Tester for headless unit testing of Custom Elements, and while I have a basic implementation configured (using a test/index.html to bootstrap everything and a test is working there), I'm having trouble with trying out a test to ES2015
import
to load components for testing.Here is the test
Here is index.js
The error output
Now, I recognize this could be a browser issue, but the version of Chrome shown in the terminal output is 67, which should have support for
import
?Is this expected? Should I be doing some additional configuration in WCT?
Let me know if you need anymore info, here is a branch with all the code and configuration. Just run
yarn install && yarn test
to reproduce.Thanks!
The text was updated successfully, but these errors were encountered: