ember-testing

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 to use custom test helper in ember.js

谁说胖子不能爱 提交于 2019-12-13 05:55:09
问题 I generated a custom test helper with: ember generate test-helper integration-for Here it is with its code removed: // tests/helpers/integration-for.js import Ember from 'ember'; export default Ember.Test.registerHelper('integrationFor', function(app, key) { return key; }); I can't get it to actually work in a component-test though. I've tried using it directly: // tests/integration/pods/components/itegration-item/component-test.js import { moduleForComponent, test } from 'ember-qunit';

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

Ember.js: Component attribute not reset while testing

纵饮孤独 提交于 2019-12-08 22:10:16
问题 I am currently attempting an acceptance test on a nested route, which makes use of the same component twice, but with different arguments. This works fine when I run it normally, however as I run the acceptance test, I notice that the component's arguments aren't being updated, which causes my test to fail. Here is some sample code: In index.hbs I have: {{index-view model=model type='location'}} My index-view component looks like this: <h1>{{title}} List</h1> {{listing-table model=model type

Ember.js ArrayController error

こ雲淡風輕ζ 提交于 2019-12-08 07:32:47
问题 I am trying to test the following sample Ember.js code but I am always getting the following error displayed in the Chrome browser console: Uncaught TypeError: Property '_super' of object [object Object] is not a function Code: MovieTracker.moviesController = Ember.ArrayController.create({ content: [], init: function(){ this._super(); var list = [ MovieTracker.Movie.create({ title: 'Movie 1', rating: 4 }), MovieTracker.Movie.create({ title: 'Movie 2', rating: 5 })]; this.set('content', list);

Instance initializer unit test fails with “store is undefined”

别等时光非礼了梦想. 提交于 2019-12-04 23:24:17
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-initializers/preload.js export function initialize( appInstance ) { let store = appInstance.lookup(