In my Meteor app, I have a form at /join
with a disabled button. I test this disabled state with the following integration test file:
// 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'
I also have a form at /signup
with a disabled button. I test that disabled state with this additional integration test file:
// 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'
Both tests pass independently of each other (i.e. when only one file exists). However, the user.signup
test only passes in absense of the user.join
test, I assume due to the way Meteor executes the files in order by filename.
It seems like beforeEach
has global scope, and the one from user.join
is overriding the one in user.signup
, causing the sign up test to execute on the wrong route and fail. Any idea why this is, or how to lock it down to local scope?
Thanks!
The problem was Iron Router. Refer to the following article for resolution: https://meteor-testing.readme.io/docs/jasmine-integration-tests-with-iron-router