【问题标题】:Meteor Velocity Jasmine: Prevent beforeEach Global Scope Across DescribesMeteor Velocity Jasmine:Prevent beforeEach Global Scope Across 描述
【发布时间】:2016-04-11 07:07:12
【问题描述】:

在我的 Meteor 应用程序中,我在 /join 有一个带有禁用按钮的表单。我使用以下集成测试文件测试此禁用状态:

// tests/jasmine/client/integration/user/joinSpec.js.coffee

describe 'user', ->

  describe 'join', ->

    beforeEach ->
      Router.go 'join_path'

    it 'is unsubmittable by default', ->
      expect($('#join-submit')).toHaveAttr 'disabled', 'disabled'

我在/signup 也有一个带有禁用按钮的表单。我用这个额外的集成测试文件测试了禁用状态:

// tests/jasmine/client/integration/user/signupSpec.js.coffee

describe 'user', ->

  describe 'signup', ->

    beforeEach ->
      Router.go 'signup_path'

    it 'is unsubmittable by default', ->
      expect($('#signup-submit')).toHaveAttr 'disabled', 'disabled'

两个测试相互独立地通过(即当只存在一个文件时)。但是,user.signup 测试仅在没有user.join 测试的情况下通过,我假设由于 Meteor 按文件名顺序执行文件的方式。

似乎beforeEach 具有全局范围,来自user.join 的那个覆盖了user.signup 中的那个,导致注册测试在错误的路径上执行并失败。知道这是为什么,或者如何将其锁定到本地范围?

谢谢!

【问题讨论】:

    标签: meteor coffeescript jasmine meteor-velocity


    【解决方案1】:

    问题出在 Iron Router 上。解决方法参考以下文章:https://meteor-testing.readme.io/docs/jasmine-integration-tests-with-iron-router

    【讨论】:

      猜你喜欢
      • 2014-05-30
      • 2016-10-21
      • 2021-05-12
      • 1970-01-01
      • 2018-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多