ember-concurrency

Ember concurrency timeout hanging in qunit

我是研究僧i 提交于 2021-01-27 20:08:46
问题 In Ember I have a component that starts a never-ending poll to keep some data up to date. Like so: export default Component.extend({ pollTask: task(function * () { while(true) { yield timeout(this.get('pollRate')); this.fetchSomeData(); } }).on('init') }) This causes a preexisting acceptance test to get stuck in this task and run forever, even though it should be run asynchronously. The test looks like this: test('my test', async function(assert) { mockFindRecord(make('fetched-model')); await

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