标签: ember-testing

PhantomJS 2.0挂在余烬测试上

我有一个简单的ember-cli应用程序.我运行单元测试ember test,在phantomJS中运行它们.使用的测试Function.prototype.bind失败,因为众所周知的幻象1.9.x缺少该API的问题.我安装了幻影2.0,但现在当我运行时ember test,在成功构建之后,测试从未运行,它只是挂在那里,没有错误,没有.

关于这里可能存在的问题,或者如何追踪它的任何想法?

操作系统是Windows.

phantomjs ember.js ember-testing ember-qunit

15
推荐指数
1
解决办法
2032
查看次数

实例初始化单元测试失败,"存储未定义"

生成示例应用程序后:

ember new preloadtest
cd preloadtest/
ember g instance-initializer preload
ember g model test-data
ember g route index
ember g adapter application
Run Code Online (Sandbox Code Playgroud)

使用以下文件:

型号/测试data.js

import DS from 'ember-data';

export default DS.Model.extend({
  name: DS.attr('string'),
  value: DS.attr( 'number' )
});
Run Code Online (Sandbox Code Playgroud)

路线/ index.js

import Ember from 'ember';

export default Ember.Route.extend({
  model(){
    return this.store.peekAll( 'test-data' );
  }
});
Run Code Online (Sandbox Code Playgroud)

实例的初始化/ preload.js

export function initialize( appInstance ) {
  let store = appInstance.lookup( 'service:store' );
  store.pushPayload( { "testDatas": [
    { "id": 1, "name": "aaa", "value": 1},
    { …
Run Code Online (Sandbox Code Playgroud)

ember.js ember-data ember-testing

14
推荐指数
1
解决办法
1360
查看次数

Ember-cli单元测试关系的需求

我正在进行单元测试,感觉我做错了.我有一个'主'对象有很多关系

author: belongsTo('person', { async: true }),
title: attr('string'),
category: belongsTo('category', { async: true }),
impact: belongsTo('impact', { async: true }),
status: attr('string'),
createdDate: attr('moment'),
submittedDate: attr('moment'),
authorOrg: belongsTo('organization', { async: true }),
locations: hasMany('location', { async: true }),
audits: hasMany('audit', { async: true })
Run Code Online (Sandbox Code Playgroud)

每次我在单元测试及其相关项目的工作时间(person,category,impact),我有重现所有的needs,我的"主"对象有值.category当我只关心字符串的名称及其与'main'对象之间的关系时,我觉得我的位置单元测试不合适

// location/model-test.js
import {
  moduleForModel,
  test
} from 'ember-qunit';

moduleForModel('location', 'Location', {
  // Specify the other units that are required for this test.
  needs: …
Run Code Online (Sandbox Code Playgroud)

unit-testing ember.js ember-testing ember-cli

11
推荐指数
1
解决办法
369
查看次数

如何在ember-qunit测试之前和之后调用hook?

在所有测试开始之前我必须执行一些代码.所以我需要使用QUnit钩子,before但在ember-qunit唯一可用的回调中是beforeEachafterEach.

我该怎么做?

javascript qunit ember.js ember-testing ember-qunit

10
推荐指数
1
解决办法
426
查看次数

如何进行路由转换的Ember集成测试?

我在使用Toran Billup的TDD指南与ember进行集成测试时遇到了问题.

我使用Karma作为Qunit和Phantom JS的测试运行员.

我肯定有一半与初学者对Ember runloop的了解有关.我的问题是两部分:

1)如何正确地将vist()测试包装到运行循环中?

2)我如何测试过渡?索引路由('/')应该转换为名为'projects.index'的资源路由.

module("Projects Integration Test:", {
  setup: function() {
    Ember.run(App, App.advanceReadiness);
  },
  teardown: function() {
    App.reset();
  }
});

test('Index Route Page', function(){
    expect(1);
    App.reset();    
        visit("/").then(function(){
            ok(exists("*"), "Found HTML");
        });
});
Run Code Online (Sandbox Code Playgroud)

提前感谢任何指向正确的方向.

tdd integration-testing ember.js ember-testing

8
推荐指数
1
解决办法
4103
查看次数

ember测试通过chrome,而不是phantomjs

我测试了一个传递chrome 的插件,但在phantomjs中失败了.

这似乎是一个类似于这个问题的问题.但是,我尝试了那里的解决方案,它对我不起作用.

代码全部在上面链接的公共仓库中提供.在github上构建失败的travis时会出现故障.关于如何更好地诊断和修复的任何想法?

编辑 - 实际的错误消息


        Died on test #1     at http://localhost:7357/assets/test-support.js:3062
            at test (http://localhost:7357/assets/test-support.js:1945)
            at test (http://localhost:7357/assets/dummy.js:2090)
            at http://localhost:7357/assets/dummy.js:2885
            at http://localhost:7357/assets/vendor.js:150
            at tryFinally (http://localhost:7357/assets/vendor.js:30)
            at http://localhost:7357/assets/vendor.js:156
            at http://localhost:7357/assets/test-loader.js:29
            at http://localhost:7357/assets/test-loader.js:21
            at http://localhost:7357/assets/test-loader.js:40
            at http://localhost:7357/assets/test-support.js:6775: Can't find variable: Symbol
Run Code Online (Sandbox Code Playgroud)

UPDATE

跟进@knownasilya的提示后,我尝试强制执行可选的babel变换es6.spec.symbols:in ember-cli-build.js:

 module.exports = function(defaults) {
   var app = new EmberAddon(defaults, {
     // Add options here
+    babel: {
+      optional: ['es6.spec.symbols']
+    }
   });
Run Code Online (Sandbox Code Playgroud)

但是 - 没有运气.不过,它确实看起来像是es6的翻译问题.我没有成功通过该选项吗?还有其他提示吗?如果您不想查看回购,我会很乐意发布代码片段.:)

更新2

包括:

+ …
Run Code Online (Sandbox Code Playgroud)

javascript phantomjs ember.js ember-testing

8
推荐指数
1
解决办法
2860
查看次数

如何在ember集成测试中对组件进行聚焦/模糊?

如何在测试Ember.js组件时触发焦点和模糊事件?

this.$().focus();this.$('input').focus();似乎工作但在phantomjs和chrome中表现不同.

this.$().blur();this.$().focusout();似乎没有工作phantomjs和铬.

jquery phantomjs ember.js ember-testing ember-components

7
推荐指数
1
解决办法
944
查看次数

在测试期间处理"后端拒绝提交,因为它无效"

我有一个使用Ember Data的ember-cli应用程序,我正在尝试编写验收测试,其中包含提交表单以提问的失败案例.在测试中,我正在使用Pretender模拟响应以返回错误对象,然后断言用户会看到一条消息,让他们知道他们的提交失败.

我写的实际断言正在传递,它会检查要显示的错误消息.问题是我也遇到了失败Error: The backend rejected the commit because it was invalid: {title: can't be blank, body: can't be blank}.

有没有办法在测试期间消除这个错误?我接近这个错误吗?在这种情况下,这实际上不是错误.后端应该拒绝提交,因为这就是我想要覆盖的内容.

这是测试:

test('errors are displayed when asking question fails', function() {
  server.post('/api/v1/questions', function(request) {
    var errors = {
      title: ["can't be blank"],
      body: ["can't be blank"],
    };

    return jsonResponse(422, { errors: errors });
  });

  authenticateSession();

  visit('/questions/new');
  click('button:contains("Ask")');

  andThen(function() {
    ok(hasContent('There were some errors with your question.'),
      'Error message displayed');
  });
});
Run Code Online (Sandbox Code Playgroud)

以及正在触发的相关行动:

save: function(model) {
  var …
Run Code Online (Sandbox Code Playgroud)

qunit ember.js ember-data ember-testing ember-cli

6
推荐指数
0
解决办法
751
查看次数

如何在Mirage中模拟二进制响应

使用Mirage我需要模拟我的GET请求,该请求以二进制字符串的形式返回数据(格式为gzip).这是我第一次使用海市蜃楼,我不知道我是否在嘲笑二元响应,我应该返回一个有效值吗?这是我现在如何嘲笑它.

  this.get('/myproxy/api/v1/network/download', function (db, request) {
    let responseBlob = new window.Blob(['To be replaced with my actual binary data'], {type: 'application/octet-stream'})
    return new Response(
      200,
      {'content-disposition': "attachment; filename=network.myextension; filename*=UTF-8''network.myextension"},
      responseBlob
    )
  })
Run Code Online (Sandbox Code Playgroud)

这是我的场景:在收到来自后端的响应后,我只是将repose转换为blob并将其下载为文件.如果我在模拟数据时应该创建有效的二进制数据,我该如何使用海市蜃楼?我应该将它作为文件存储在某处并将其用作模拟响应吗?如果有人可以帮助我,我感激不尽.

ember.js ember-testing ember-cli-mirage

6
推荐指数
1
解决办法
287
查看次数

Ember.js:测试时组件属性未重置

我目前正在尝试对嵌套路由进行验收测试,该路由使用相同的组件两次,但使用不同的参数.这在我正常运行时工作正常,但是当我运行验收测试时,我注意到组件的参数没有被更新,这导致我的测试失败.以下是一些示例代码:

index.hbs我有:

{{index-view model=model type='location'}}
Run Code Online (Sandbox Code Playgroud)

我的index-view组件看起来像这样:

<h1>{{title}} List</h1>

{{listing-table model=model type=type}}
Run Code Online (Sandbox Code Playgroud)

通过点击的一个元素listing-table,然后我去的locations.show路线,其中包含link-tolocations.show.devices路线.该locations.show.devices路线包含:

{{listing-table model=model.devices type='device' exclude='locationName'}}
Run Code Online (Sandbox Code Playgroud)

然而,在我的验收测试,我可以看到(呼应出器件的javascript这些属性),虽然modeltype正在更新,exclude始终设置为当组件最初叫什么设置.

现在,我已经检查(通过console.log())组件是否被重复使用或没有,我可以看到,无论是init ()didDestroyElement ()被调用两次,这意味着该组件经历的整个生命周期的两倍.但是,我真的不明白为什么我的exclude论点根本没有更新,为什么这只会在验收测试时发生?

这是我正在做的精简版(当然它适用于Twiddle,但不适用于现实生活!).

javascript acceptance-testing ember.js ember-testing

6
推荐指数
1
解决办法
169
查看次数