Closed lljr closed 4 years ago
Does the stack trace tell you more (details about the error)?
_loadResource(data) {
let record;
let { id, type, attributes, relationships } = data;
if (type === 'bands') {
let rels = extractRelationships(relationships);
record = new Band({ id, ...attributes }, rels);
this.add('band', record);
}
if (type === 'songs') {
let rels = extractRelationships(relationships);
record = new Song({ id, ...attributes }, rels);
this.add('song', record);
}
return record;
}
import { Model, hasMany } from 'ember-cli-mirage';
export default Model.extend({
songs: hasMany()
});
import { Model, belongsTo } from 'ember-cli-mirage';
export default Model.extend({
band: belongsTo()
});
The error says it timed out waiting for [data-test-rr="no-songs-text"]
.
Do you have that attribute attached to the DOM element (the p
tag)?
in templates/bands/band/songs.hbs
{{else}}
<p class="text-center" data-test-rr="no-songs-text">
The band has no songs yet.
</p>
{{/if}}
The waitFor
that you have in the test still says waitFor('p.text-center')
but the error thrown says it was waiting for [data-test-rr="no-songs-text"]
. That's interesting but I'll assume the test code you pasted is an earlier version.
Anyway, if you put an await this.pauseTest()
before the waitFor
line, do you see the element that's waited for (the p
just here above, in the previous template snippet)?
I just got back to this error. I redid everything from Chapter 1 to this point. I still have issues passing these tests.
It's weird because it says that the bandLinks
are not rendered, yet when I await this.pauseTest()
before waitFor
, the links are rendered. Look below
Now look when I run the tests without the await this.pauseTest()
Ok... I found out... I misspelled bandLinks.length
with bandLinks.legth
...
I get this error when I insert
await waitFor('p.text-center')
->Promise rejected during "Create a band": waitFor timed out waiting for selector "p.text-center"@ 1385 ms
in
index.hbs
I have<p class="text-center">Select a band.</p>
. and inbands-test.js
->config.js
mirage/serializers/application.js
Actually, this may be the error: