question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New style tests fail on visit()

See original GitHub issue

I 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:

https://github.com/emberjs/ember-test-helpers/blob/3f34686c527b691cf787037bc7dabb24b2fbdde2/addon-test-support/%40ember/test-helpers/setup-application-context.js#L19

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:closed
  • Created 6 years ago
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
Turbo87commented, Mar 26, 2018

summary of this issue:

  1. setApplication() stuff is not documented, fixed by https://github.com/emberjs/ember-qunit/pull/320

  2. docs for ember-mocha are missing, fixed by https://github.com/emberjs/ember-mocha/pull/200

  3. support for new testing APIs in ember-cli-mirage, fixed by https://github.com/samselikoff/ember-cli-mirage/pull/1263

I’m closing this issue now since all of the mentioned issues have been addressed.

1reaction
rwjbluecommented, Feb 15, 2018

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…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found