Open michaelw85 opened 5 years ago
cli-bundler requirejs web typescript karma vscode scaffold-minimum
With test:
import { bootstrap } from 'aurelia-bootstrapper';
import { ComponentTester, StageComponent, waitForDocumentElement } from 'aurelia-testing';
describe('Icon', () => {
let component: ComponentTester;
describe('component', () => {
beforeEach(() => {
component = StageComponent.withResources('my-icon').inView('<my-icon name="angle-up"></my-icon>');
});
it('should render svg icon with href', async () => {
await component.create(bootstrap);
const myIcon = await waitForDocumentElement('my-icon')
expect(myIcon.innerHTML.trim()).toContain('href="src/assets/stack.svg#angle-up"');
});
afterEach(() => {
try {
component.dispose()
} catch {
console.log('dispose error')
}
});
});
});
It works fine. I think there's something wrong with Jest.
@michaelw85 The above is for your my-icon
@bigopon 😲 thx for the reply I did not consider Jest to cause the issue... 🤔 I wonder what it could be.
@michaelw85 maybe Jest is not the issue, but the combination of Jest and a few other stuff? In anyway, I think for normal looking templates, it will & should work just fine
I might investigate a bit more at a later point in time. First thing that pops in my mind is if it might be related to testEnvironment: 'node',
.
I'm submitting a bug report ref and innerhtml not working when using the component tester.
au jest will result in an error for the ref issue. the innerhtml issue is visible in the jest snapshot.
To verify the icons are actually functioning in a normal app use
au run
to open the dev-app.Please tell us about your environment:
Operating System: Windows 10
Node Version: v10.15.0
NPM Version: 6.9.0
JSPM OR Webpack AND Version Plugin setup created with CLI, default TS configuration
Language: TS
Current behavior: When using a ref binding it is undefined in a unit test when using the component tester.
TypeError: Cannot read property 'setAttribute' of undefined
(setAttribute is performed on the elements being referenced)innerhtml is not rendered, here's a jest snapshot:
Expected/desired behavior: ref should work when using the component tester. innerhtml binding should render when using component tester.