New style tests fail on visit()
See original GitHub issueI have just upgraded my app to Ember 3, and wanted to try out the new style tests.
So I generated a new, super basic test (ember g acceptance-test new-style
), and tried to run it:
import { module, test } from 'qunit';
import { visit, currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
module('Acceptance | new style', function(hooks) {
setupApplicationTest(hooks);
test('visiting /login', async function(assert) {
await visit('/login');
assert.equal(currentURL(), '/login');
});
});
However, I get the following error:
TypeError: Cannot read property 'apply' of undefined
at setup-application-context.js:27
at tryCatcher (rsvp.js:215)
at invokeCallback (rsvp.js:393)
at publish (rsvp.js:379)
at rsvp.js:10
at invoke (backburner.js:205)
at Queue.flush (backburner.js:125)
at DeferredActionQueues.flush (backburner.js:278)
at Backburner.end (backburner.js:410)
at Backburner._boundAutorunEnd (backburner.js:372)
After some debugging, the problem seems to be that in the setup-application-context.js, in this line:
owner
doesn’t seem to have a visit
method. When I look at the owner
object in the debugger, I see that it only has __container__
and __registry__
properties.
I have updated to all the latest versions of everything, as far as I see:
- ember-cli-qunit: 4.3.1
- ember-qunit: 3.3.1
- @ ember/test-helpers: 0.7.17
- ember-cli: 3.0.0
- ember-source: 3.0.0
- ember-data: 3.0.1
Issue Analytics
- State:
- Created 6 years ago
- Comments:20 (10 by maintainers)
Top Results From Across the Web
Page occasionally does not load from cy.visit() #2938 - GitHub
I tried replacing the get click with visit(url) and I see the same error, it doesn't appear to matter how the url is...
Read more >Cypress - cy.visit() failed trying to load - Stack Overflow
In my case, it was a slow running test that triggered a timeout of cypress itself. I could fix ...
Read more >Error Messages | Cypress Documentation
Test File Errors No tests found This message means that Cypress was unable ... cy.visit() failed because you are attempting to visit a...
Read more >8 common mistakes in Cypress (and how to avoid them)
But what about the cases when our tests fail because the page is too slow? Feels like using cy.wait() is the way to...
Read more >Cypress cy.intercept Problems - Gleb Bahmutov
In our case, we need to register the intercept before visiting the page. ... cy.get('.new-todo').type('Write a test{enter}')
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
summary of this issue:
setApplication()
stuff is not documented, fixed by https://github.com/emberjs/ember-qunit/pull/320docs for
ember-mocha
are missing, fixed by https://github.com/emberjs/ember-mocha/pull/200support for new testing APIs in
ember-cli-mirage
, fixed by https://github.com/samselikoff/ember-cli-mirage/pull/1263I’m closing this issue now since all of the mentioned issues have been addressed.
I’m fairly certain that your application is not use
setApplication
in its tests/test-helper.js file. This forces us to make a “fake” owner which only has the registry / container interface.We need to add helpful assertions in setup application context when their isn’t an application set…