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.

beta.2 model unit tests failing w/codemod

See original GitHub issue

version ember-cli-qunit 4.1.0-beta.2

Synopsis

Just read @rwjblue blog post and ran the codemod converting the tests to 4.1.0-beta.2 tests API.

I ran codemod incrementally, and most of the codemod changes produced successful converstions with passing tests. Two exceptions are tests/unit/models/* and tests/integration/components/* which are failing.

Here is an example for a model unit test

before codemod:

tests/unit/models/user-test.js

import { moduleForModel, test } from 'ember-qunit';

moduleForModel('user', 'Unit | Model | user', {
  // Specify the other units that are required for this test.
  needs: [
    'validator:confirmation',
    'validator:format',
    'validator:length',
    'validator:presence',
  ],
});

test('it exists', function(assert) {
  let model = this.subject();
  // let store = this.store();
  assert.ok(!!model);
});

after codemod

import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('Unit | Model | user', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let model = this.owner.lookup('service:store').createRecord('user');
    // let store = this.store();
    assert.ok(!!model);
  });
});

error

Error: Assertion Failed: You have turned on testing mode, which disabled the run-loop's autorun. You will need to wrap any code with asynchronous side-effects in a run
    at new EmberError (http://localhost:4200/assets/vendor.js:24282:25)
    at Object.assert (http://localhost:4200/assets/vendor.js:24524:15)
    at Function.run.schedule (http://localhost:4200/assets/vendor.js:37739:76)
    at RecordArrayManager.internalModelDidChange (http://localhost:4200/assets/vendor.js:174641:16)
    at RecordArrayManager.recordDidChange (http://localhost:4200/assets/vendor.js:174616:10)
    at InternalModel.updateRecordArrays (http://localhost:4200/assets/vendor.js:172521:35)
    at InternalModel.transitionTo (http://localhost:4200/assets/vendor.js:172338:10)
    at Object.loadedData (http://localhost:4200/assets/vendor.js:166171:21)
    at InternalModel.send (http://localhost:4200/assets/vendor.js:172225:30)
    at InternalModel.loadedData (http://localhost:4200/assets/vendor.js:172106:10)

screen shot 2017-10-27 at 7 37 22 am

repo/branch: https://github.com/mirai-audio/mir/tree/testing-qunit-codemod/tests

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
rwjbluecommented, Oct 29, 2017

Awesome, thanks for working through that @0xadada!

1reaction
rwjbluecommented, Oct 28, 2017

Awesome, thanks for digging! The specific issue you are hitting with the rendering test is indeed an issue with the ember-test-component addon (see https://github.com/poteto/ember-test-component/issues/6, and https://github.com/poteto/ember-test-component/pull/7).

You can work around (if you want to) via something like this:

module('Integration | Component | ma auth', function(hooks) {
  setupRenderingTest(hooks);

  hooks.beforeEach(function() {
    Ember.setOwner(this, this.owner);
  });

  // .... existing contents ....
});

Note: this is really just a work around until https://github.com/poteto/ember-test-component/pull/7 lands…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Xcode 14.1 beta 3 unit test fail d… | Apple Developer Forums
Xcode 14.1 beta 3 unit test fail due to copy paste permission still appearing every time I run the tests.
Read more >
"No such module" when using @testable in Xcode Unit tests
The "No such module" error was gone for me. In case this doesn't solve the problem for other people, you can also try...
Read more >
Unit Testing Tutorial – What is, Types & Test Example - Guru99
Depending on the severity of a failure, the framework may halt subsequent testing. The workflow of Unit Testing is 1) Create Test Cases...
Read more >
Best practices for writing unit tests - .NET - Microsoft Learn
This article describes some best practices regarding unit test design ... Whether or not the test passes or fails is up to the...
Read more >
Testing Models in Swift | Codecademy
A function that tests something in our codebase is called a unit test. This unit test is responsible for testing for edge cases,...
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