I’m working in a project that is largely untested, unfortunately we have some instances of markup that appears to require refactoring in order to be testable.
For example, when the HTML contains value.bind or class.bind or checked.bind the test fails, an example of value.bind error below.
import { ComponentTester, StageComponent } from "aurelia-testing";
import { bootstrap } from "aurelia-bootstrapper";
import { PLATFORM } from "aurelia-pal";
import * as path from "path";
import { Options } from "aurelia-loader-nodejs";
Options.relativeToDir = path.join(__dirname);
describe("MyComponent", () => {
let component: ComponentTester;
beforeEach(() => {
component = StageComponent.withResources(
PLATFORM.moduleName("./component")
).inView("<component></component>")
.boundTo({ value: "foo" });
});
it("should render", (done) => {
component
.create(bootstrap)
.then(() => {
const element = document.querySelector(".bar");
expect(element).toBeTruthy();
done();
})
.catch((e) => {
console.log(e.toString());
});
});
Error: The value property of a object ([object HTMLInputElement]) cannot be assigned.
Is there a workaround to using value.bind? I’ve seen code examples on discourse using value.bind, so maybe there is something particular about the configuration of our tests.
Somehow having both value and value.bind attributes seems excessive.
Also, from your code it is unclear why you provide resources to a template that does not have a component.
Level 18 385 Bourke Street
Melbourne, Victoria, 3000
The contents of this email originated from Iress. For this purpose Iress includes Iress Limited and/or any of its subsidiaries, holding companies and trading entities. If you have received this email in error please notify the sender immediately and delete this email.