Meteor Velocity Jasmine:防止beforeEach Global Scope Across Describes

Meteor Velocity Jasmine: Prevent beforeEach Global Scope Across Describes

在我的 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 中的那个,导致注册测试在错误的路由上执行并失败.知道为什么会这样,或者如何将其锁定到本地范围?

谢谢!

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