jejacks0n / teaspoon

Teaspoon: Javascript test runner for Rails. Use Selenium, BrowserStack, or PhantomJS.
1.43k stars 243 forks source link

Tests in individual test files pass, but almost all tests fail when running all files #417

Closed toppa closed 9 years ago

toppa commented 9 years ago

I've puzzled over this for a while, and can't figure it out. When I run a specific test file, my tests pass:

bundle exec teaspoon spec/javascripts/my_test_file.js.coffee

Finished in 0.02900 seconds
32 examples, 0 failures

But when I do this, almost all the tests in all the test files fail:

bundle exec teaspoon

Finished in 0.16900 seconds
389 examples, 381 failures

Same thing with rake teaspoon. I'm using teaspoon-mocha 2.2.4. I'm not sure what info would be most useful to share, so instead of randomly pasting hundreds of lines of code here, if you have an idea where would be good to begin, I'll very happily do what I can to help sort this out. Thanks!

toppa commented 9 years ago

...And as soon as I posted that, I think I've realized the problem. I have a series of "CustomerValueModel" classes, and a test file for each one. The class files each live in different subdirectories, but they all have the same class name. In the web app, there is one loaded per page, so they never interfere with each other. I'm guessing in Teaspoon, when I run the suite, they are colliding with each other in some fashion (I require each class file at the top of its test file). All the errors happen in method calls, with "Failure/Error: undefined is not a constructor". Is there a way to isolate the runs of each test file from the others, short of making a separate Teaspoon suite for every test file?

toppa commented 9 years ago

And I resolved it by reworking the app structure a bit so all the class names are unique. Now my test suite is running fine. I am my own rubber duck.

jejacks0n commented 9 years ago

:) I enjoy seeing people solve their issues, no worries.


Jeremy Jackson

On Oct 2, 2015, at 8:31 PM, Michael Toppa notifications@github.com wrote:

And I resolved it by reworking the app structure a bit so all the class names are unique. Now my test suite is running fine. I am my own rubber duck.

— Reply to this email directly or view it on GitHub.

mikepack commented 9 years ago

🍺

On Oct 2, 2015, at 9:16 PM, Jeremy Jackson notifications@github.com wrote:

:) I enjoy seeing people solve their issues, no worries.


Jeremy Jackson

On Oct 2, 2015, at 8:31 PM, Michael Toppa notifications@github.com wrote:

And I resolved it by reworking the app structure a bit so all the class names are unique. Now my test suite is running fine. I am my own rubber duck.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub.