Hello everyone,
I’m trying to test a simple component output:
import {StageComponent} from 'aurelia-testing';
import {bootstrap} from 'aurelia-bootstrapper';
import {PLATFORM} from 'aurelia-pal';
describe('Account Details', () => {
let component;
beforeEach(() => {
component = StageComponent
.withResources(PLATFORM.moduleName('account-details'))
.inView('<account-details"></account-details>');
});
it('should render first name', done => {
component.create(bootstrap).then(() => {
console.log(component.element);
expect(component.element.textContent).toBe('No details yet.');
done();
}).catch(e => { console.log(e.toString()) });
});
afterEach(() => {
component.dispose();
});
});
<template>
<div class="account-details">${message}</div>
</template>
import { inject, customElement, bindable, useView } from 'aurelia-framework';
import {PLATFORM} from 'aurelia-pal';
@useView(PLATFORM.moduleName('account-details.html'))
@customElement('account-details')
@inject(Element)
export class AccountDetails {
message = "No details yet.";
constructor(element) {
this.element = element;
}
}
How can I test the output of the component?
“No details yet.”
when try component element, I get :
_ HTMLUnknownElement {
[Symbol(SameObject caches)]: [Object: null prototype] {
attributes: NamedNodeMap {},
style: CSSStyleDeclaration {
_values: {},
_importants: {},
_length: 0,
onChange: [Function (anonymous)]
},
dataset: DOMStringMap {},
classList: DOMTokenList {},
children: HTMLCollection {}
}
}
If I try document.querySelector("div.account-details");
I’ve got NULL
On component.element.innerText
=> undefined