ember-testing

Unit testing ember-concurrency tasks and yields

匆匆过客 提交于 2020-01-25 04:35:07
问题 We have a lot of code in our project that isn't covered because of ember concurrency tasks. Is there a straightforward way of unit testing an controller that contains something like the following: export default Controller.extend({ updateProject: task(function* () { this.model.project.set('title', this.newTitle); try { yield this.model.project.save(); this.growl.success('success'); } catch (error) { this.growl.alert(error.message); } }) });``` 回答1: You can unit test a task like that by

Delay tests till Ember.run.later is done

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-05 09:29:09
问题 I am trying to get some tests to pass for an ember addon. It was working fine until yesterday I added some code that runs later in the run loops using Em.run.next. Here is what Im doing in my test. visit('/').then(function() { find('bm-select').click(); andThen(function() { equal(1,1, 'yay'); }); }); The problem is when click is triggered, the later function is executed after andThen . By that time all my tests are done and it throws error. I am under the impression andThen should wait for

ember integration test error. dealing with asynchronous side-effects

放肆的年华 提交于 2020-01-05 07:51:00
问题 I'm trying ember's integration testing package (http://emberjs.com/guides/testing/integration/) but I am getting this 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 an Ember.run I've made a JSBin to reproduce this error: http://jsbin.com/InONiLe/9, which we can see by opening up the browser's console. I believe what's causing this error is the line data.set('isLoaded', true); in

ember integration test error. dealing with asynchronous side-effects

岁酱吖の 提交于 2020-01-05 07:49:54
问题 I'm trying ember's integration testing package (http://emberjs.com/guides/testing/integration/) but I am getting this 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 an Ember.run I've made a JSBin to reproduce this error: http://jsbin.com/InONiLe/9, which we can see by opening up the browser's console. I believe what's causing this error is the line data.set('isLoaded', true); in

Ember-auth QUnit tests fail every second run

情到浓时终转凉″ 提交于 2020-01-04 04:45:16
问题 I have recently managed to get my ember-auth tests to pass, but it's not yet perfect, as the tests fail every second time (or if there are several tests running, every second test about authentication fails). I have created a small sample app to demonstrate the failure. You should be able to reproduce the failure by following these steps: 1. git clone https://github.com/pedrokost/ember_auth_testing_example.git 2. cd ember_auth_testing_example 3. ruby -run -e httpd . -p5000 # (or any HTTP

Introduce momentary delays in ember-cli-mirage

纵饮孤独 提交于 2020-01-03 03:30:30
问题 I am using ember-cli-mirage for acceptance tests. For a specific case, I would like to check the behaviour while fetching data over a slow connection. There's a setting in ember-cli-mirage called timing that simulates a delay in the response. However, this setting cannot be changed to be different in a specific test: // app/mirage/config.js this.timing = 400; Something else I have tried is returning a promise at the fake endpoint. Through some import/export, I could control the resolution of

Instance initializer unit test fails with “store is undefined”

瘦欲@ 提交于 2020-01-02 01:04:12
问题 After generating an example application: ember new preloadtest cd preloadtest/ ember g instance-initializer preload ember g model test-data ember g route index ember g adapter application With the following files: models/test-data.js import DS from 'ember-data'; export default DS.Model.extend({ name: DS.attr('string'), value: DS.attr( 'number' ) }); routes/index.js import Ember from 'ember'; export default Ember.Route.extend({ model(){ return this.store.peekAll( 'test-data' ); } }); instance

Ember integration testing hangs after visiting route

◇◆丶佛笑我妖孽 提交于 2019-12-24 13:32:56
问题 I am trying to do a simple integration test and I started from the integration example on the ember-cli website. Right now when I test in a browser (localhost:4200/tests), the follow case routes to where I expect, but then it just hangs and never does success or failure. import Ember from "ember"; import { test } from 'ember-qunit'; import startApp from '../helpers/start-app'; var App; module('Integration - Create Event', { setup: function() { App = startApp(); }, teardown: function() { Ember

Ember testing: You have turned on testing mode, which disabled the run-loop's autorun

你离开我真会死。 提交于 2019-12-23 09:27:15
问题 I am trying to write a simple Ember integration test and continue to get the frustrating run loop error despite using Ember.run . I've had a nightmare of a time trying to get this to work, if anyone could help me I'd be so grateful. Specifically, I can see the test sign in and begin loading the next page (as it should), but as soon as the test finishes I get that error. This is regarding the second test, the first passes (as nothing is async I believe). import Ember from 'ember'; import

ember tests passing in chrome, not in phantomjs

穿精又带淫゛_ 提交于 2019-12-22 04:34:08
问题 I have tests for an addon which pass in chrome, but fail in phantomjs. It seems to be a problem similar to this question. However, I tried the solution there and it didn't work for me. The code is all available in the public repo linked above. The failures are exhibited in the failing travis build on github. Any ideas on how to diagnose better and fix? EDIT -- actual error message Died on test #1 at http://localhost:7357/assets/test-support.js:3062 at test (http://localhost:7357/assets/test