beta.2 model unit tests failing w/codemod
See original GitHub issueversion 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)
repo/branch: https://github.com/mirai-audio/mir/tree/testing-qunit-codemod/tests
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top 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 >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
Awesome, thanks for working through that @0xadada!
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:
Note: this is really just a work around until https://github.com/poteto/ember-test-component/pull/7 lands…