简体   繁体   中英

Jasmine-node tests always pass

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

Project@0.0.0 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

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();
  });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM