Reputation: 35
I'm new to BDD and for some reason my code always seem to be passing although I haven't yet written any code. Can somebody please explain why this is happening?
Project setup:
I have a project folder with package.json and a test section with the following declared: ".node_modules/.bin/jasmine-node" and a folder called spec with the following code file:
var request = require("request");
describe("Web Server Test", function() {
it("GET /", function(done) {
request.get("http://localhost/", function(error, request, body) {
expect(body).toContain("Hello, World!");
});
done();
});
});
This is the output I get:
C:\Users\\OneDrive\Documents\Websites\Projects\Node\project>npm test spec/app_spec.js
[email protected] test C:\Users\\OneDrive\Documents\Websites\Projects\Node\project jasmine-node "spec/app_spec.js"
.
Finished in 0.031 seconds 1 test, 0 assertions, 0 failures, 0 skipped
Upvotes: 0
Views: 292
Reputation: 14199
the done
callback must be called inside request callback...
it("GET /", function(done) {
request.get("http://localhost/", function(error, request, body) {
expect(body).toContain("Hello, World!");
// THIS IS ASYNC
done();
});
});
Upvotes: 1