Closed blazer82 closed 10 years ago
I just found that when you place an additional server.eval(...).once(...)
within the last test everything works fine again. The problem seems to be with the nature of the test being client-side only.
Might actually be related to #48
I found that when you set your initial apps in the AppPool to a number high enough to execute every test on one of those initially started apps (in this case here size: 3
) then everything runs fine again. Although this cannot be a solution it suggests that something isn't quite ready while executing the last test.
The same conclusion can be reached by applying the following patch to lib/app.js:56
- self.emit('ready', laikaInjectPort);
+ setTimeout(function() {
+ self.emit('ready', laikaInjectPort);
+ }, 1000);
Delaying the emission of ready
also leads to a working and therefore passing third test. Once again, something didn't seem to be ready even though it should have been.
But this wouldn't be a very nice solution either. I'm going to investigate further, just wanted to share my results here.
I got it. I'm going to make a pull request for the fix...
Hey Blazer82. It seems this issue exits again as of meteor 8.1.1. Yesterday I was running test and when I swapped the order around, it consistently failed every third test. Adding a server side eval like you said a few comments ago does fix the problem. Laika -v is 0.3.9 and node -v is 0.10.28 Code is below. Please see issue #117
// Login.js
var assert = require('assert');
suite('Home Page', function() {
test('should display a login link instead of username when not logged in', function(done, server, client) {
client.eval(function() {
Router.go('/');
waitForDOM('li', function() {
emit('login-link-text', $('#sign-in-button').text());
});
emit('return');
}).once('login-link-text', function(text) {
assert.equal(text, 'Sign In');
}).once('return', function() {
done();
});
// allows 3rd test to pass
server.eval(function() {
emit('return');
}).once('return', function() {
done();
});
});
});
// promotions.js
var assert = require('assert');
suite('Promotions', function() {
test('in the server', function(done, server) {
server.eval(function() {
Promotions.insert({
promoName: 'testName',
blurb: 'test',
latitude: '43.011338',
longitude: '-83.713344',
startDate: 'Jul 9th, 2009',
endDate: 'Dec 23rd, 2012',
daysBetween: '1264',
author: 'admin'
});
var docs = Promotions.find({promoName: 'testName'}).fetch();
emit('docs', docs);
}).once('docs', function(docs) {
assert.equal(docs.length, 1);
done();
});
});
test('access denied when not logged in', function(done, server, client) {
client.eval(function() {
Promotions.find().observe({
removed: onRemoved
});
function onRemoved(promotion) {
emit('remove', promotion);
emit('return');
}
Promotions.insert({promoName: 'testRemove'});
}).once('remove', function(promotion) {
assert.equal(promotion.promoName, 'testRemove');
}).once('return', function() {
done();
});
// allows 3rd test to pass
server.eval(function() {
emit('return');
}).once('return', function() {
done();
});
});
});
I have a really strange behavior with my test suite: After two server-side tests the next client-side test fails because of a timeout, always and even if the timeout is set to really high values. I tried to track it down but wasn't able to find anything. It seems to be completely independent of any meteor app, since it's easily reproducible in another app. All you need to do is to run the following tests:
Nothing special here, just some asserting that
true
equalstrue
. And if you remove the first or the second test, everything works fine again. I noticed something strange during the execution of the third test. It seems as if the app is getting launched three times:You can place all those tests within the same suite and you'll get the same results. So far, I found no way to avoid this problem. Any ideas what might be causing this?