jasmine / jasmine-npm

A jasmine runner for node projects.
MIT License
377 stars 145 forks source link

This function never exeuted. #151

Closed nobody4t closed 5 years ago

nobody4t commented 5 years ago

I try to test a function which includes the snippet as following. But This got never executed. I tried with asynchronous and timeout. But none is available. But I can execute it from a script. Not sure what is going here.

    let request = await https.get(reqUrl, function(res){
    let file = fs.createWriteStream(dest);
    res.pipe(file);
    file.on("finish", function(){
        file.close(function(){
            console.log("Connection download completely.");
        });
    });
});
nobody4t commented 5 years ago

This request should spend 20s. But in the spec, it just returns after 0.04s.

nobody4t commented 5 years ago

This is my test code.

     it("Test download connection file.", async() => {
                if (!url) {
                    fail("Please specify your url.");
                }
        expect(utils.downloadConnectionFile).toBeDefined();
        let opts = {url:url, key:"Ppp", secret:"kAjqE_hrW7oruc8U8BYCY9ceUaMrNFnbJ4qzIufCLZAKkBHXfcS"};
        await utils.downloadConnectionFile(opts, conFile);

        let result = fs.existsSync(conFile);
        expect(result).toBe(true);
    });
nobody4t commented 5 years ago

This is the cause I misused the createWriteStream. Sorry.