ember-qunit

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

How to test an Ember model's computed property that has relations dependencies?

与世无争的帅哥 提交于 2019-12-24 10:40:04
问题 I'm writing Qunit tests to test An Ember model, but having a hard time testing computed properties that have a relation dependency (the computed property triggers another model's computed property). The model that am testing (CoffeeScript): Customer = DS.Model.extend firstName: DS.attr('string') lastName: DS.attr('string') phones: DS.attr('embedded-list') phone: (-> @get('phones.firstObject.number') ).property('phones.firstObject.number') fullName: (-> [@get('lastName'), @get('firstName')]

Injecting service into a mixin Ember2.3+

*爱你&永不变心* 提交于 2019-12-24 00:46:31
问题 I am having a problem with an error that pops up in my unit test suite when I try to check a service injected into Mixin since getOwner() has been added into Ember (deprecation guide here). This is my mixin: import Ember from 'ember'; export default Ember.Mixin.create({ sha: Ember.inject.service('sha512'), }); This is my basic unit test slightly changed after being generated by ember-cli: import Ember from 'ember'; import DirtyRelationshipsDetectorMixin from 'xamoom-customer/mixins/dirty

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

Initialized dependency not present when testing

旧巷老猫 提交于 2019-12-22 08:46:27
问题 I'm using ember-cli 0.0.35, and injecting a dependency onto my component via an initializer. It works great in development, but the property isn't present when I run tests. It appears that testing calls loadInitializers, but the dependency is not showing up on this.subject({}); I don't want to manually inject it for the tests. Is there a better way to handle this? Initializer: var FooServiceInitializer = { name: 'foo', initialize: function (container, application) { application.inject(

ember render hbs swallowing thrown error

守給你的承諾、 提交于 2019-12-18 16:55:28
问题 I have a simple component integration test: test('it throws error my-custom-input is called', function(assert) { assert.throws(() => { this.render(hbs`{{my-custom-input}}`); }, /my-custom-input component error/, 'Error must have been thrown'); }); Source code of component.js is like: export default Ember.Component.extend({ layout, init() { this._super(...arguments); throw 'my-custom-input component error'; } } While my ember-cli version was 2.3.0, the test was passing. However, after I've

How to stub component's action in ember?

前提是你 提交于 2019-12-14 02:24:52
问题 I created a component, whose action uses store service. How can I stub this action from integration test? // app/components/invoice-form.js export default Ember.Component.extend({ actions: { loadPartners() { let self = this; this.get('store').findAll('partner').then(function(partners) { self.set('partners', partners); }); } } }); In this component's template I pass this action as closure to child component: {{button-confirmation text="Are you sure?" onConfirm=(action "loadPartners")}} In my

How does ember-qunit render components in integration testing?

南楼画角 提交于 2019-12-11 04:52:47
问题 Here is a basic component / integration test for ember-qunit. import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; moduleForComponent('my-component', 'TODO: put something here', { integration: true }); test('it renders', function(assert) { this.render(hbs`{{my-component}}`); console.log('This is the rendered element', this.$()[0]); assert.ok(false); }); I have an ember-addon with a directory structure like this: addon/ .. components/ .... my

EmberJS: How to test a controller action with moduleFor of ember-qunit, which uses store of ember-data

五迷三道 提交于 2019-12-11 03:22:20
问题 I want to test a controller action like this: createNewBase: function () { var attributesForNewBase = this.get( 'model' ).getProperties( ... ), self = this, newBase = this.store.createRecord( ..., { ... } ); newBase.save().then( function ( createdBase ) { self.send( 'setBaseOfModel', createdBase ); }, function ( error ) { console.log( error ); } ); } The problem is that if I use moduleFor of ember-qunit to test this action the store is undefined. So what do I have to do or what is the correct

Having trouble unit testing a helper from an addon project

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 20:53:28
问题 https://github.com/stefanpenner/ember-cli/issues/2421 ember-cli: 1.2 I have a boilerplate addon project that has a title-case helper as follows: My Helper app/helpers/title-case.js import Ember from 'ember'; export default Ember.Handlebars.makeBoundHelper(function(string) { if (typeof string === 'string') { //replace dashes with spaces var str = string.dasherize().replace(/-/g, ' '); return str.replace(/\w\S*/g, function(word){ return word.charAt(0).toUpperCase() + word.substr(1).toLowerCase(