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.

pauseTest() does not work as expected

See original GitHub issue

Currently the pauseTest() helper doesn’t work properly with mocha due to its test timeouts. If you call this.timeout(0); before using pauseTest() it will work, but obviously it would be better if this could be done automatically.

Is it possible for us to overwrite the original pauseTest() helper and add one that first calls this.timeout(0) and the original code afterwards?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
Turbo87commented, Jun 5, 2018

This has been solved with the new testing API released in v0.14.0

1reaction
alexlafrosciacommented, Nov 27, 2016

I’ve been playing around with this some, and have had trouble overriding the existing pauseTest helper to set the timeout. However, introducing a new helper works.

What I did to override the existing helper was adding this to the test-helper.js for a demo app:

import { before } from 'mocha';

before(function() {
  const originalPauseTestHelper = Ember.Test._helpers.pauseTest.method;

  Ember.Test.registerAsyncHelper('pauseTest', () => {
    this.timeout(0);

    return originalPauseTestHelper();
  });
});

My hope was that setting the timeout in here would override the default value of 2000 and cause the test now to fail. However, this doesn’t work; I’m guessing that’s the case because the context (this) of the before hook needs to be set up before the it callback is called, but in this case we’re setting it after the test has already started.

What did work was setting up a new helper, like this:

import { before } from 'mocha';

before(function() {
  const originalPauseTestHelper = Ember.Test._helpers.pauseTest.method;

  Ember.Test.registerAsyncHelper('pauseMochaTest', (app, context) => {
    context.timeout(0);

    return originalPauseTestHelper();
  });
});

In this case, the tests passes the context into the helper, like:

pauseMochaTest(this);

So now it can set the timeout correctly, because it’s accessing the context of the it callback instead of the context of the before.

I’ve tried to see if there’s some way to access the it context from the before but it doesn’t seem possible. How do you feel about “solving” this with a new helper?

Read more comments on GitHub >

github_iconTop Results From Across the Web

'ReferenceError: pauseTest is not defined' in integration tests ...
It's working fine in Acceptance tests, because of: // ./tests/helpers/start-app.js export default function startApp( ...
Read more >
Testing Application - Ember Guides
In order to help you understand why, pauseTest() and resumeTest() can help you. To try them out, do the following steps: Add await...
Read more >
Productive debugging - DockYard
Inserting a call to pauseTest() inside an acceptance test will pause the test suite at the point that it sees the function call....
Read more >
How to Debug Cypress Tests : Tutorial | BrowserStack
//debugger might not work in expected way it('Click on Sign In', () => { cy.get('a[title="Sign In"]').click() debugger; }).
Read more >
ember-qunit | Yarn - Package Manager
... #497 Work around issue with pauseTest() timing out. ... #165; Called start() outside of a test context #143; problem returning application from...
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