小编Jac*_*ack的帖子

jasmine IT 块在“beforeAll”块之前执行

在 VSCode 中的 node.js 项目中,我尝试在运行规范之前读取配置信息。但我的规范总是在“beforeAll”块之前首先执行。

\n\n
beforeAll(() => {\n    console.log(\'Step0\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6..: \');\n    return new Promise(resolve => {\n        console.log(\'Step1\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6..: \');\n\n        browser.getProcessedConfig().then((config) => {            \n            console.log(\'environment 12: \' );\n            resolve(true);\n        });    \n    });\n});\n\ndescribe(\'*************************Executing TestSuite************************\', function () {\n    console.log(\'Step2\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6..: \');\n    it("should support async execution of test preparation and expectations", function() {\n        expect(3).toBeGreaterThan(0);\n    });   \n});//describe\n
Run Code Online (Sandbox Code Playgroud)\n\n

我尝试简化代码以仅保留一个期望语句,但它仍然是相同的。

\n\n

我得到的当前输出是 Step 2 、 Step 0 、 Step 1

\n\n

我期待的是步骤 0、步骤 1、步骤 2

\n

javascript node.js jasmine protractor

5
推荐指数
1
解决办法
1965
查看次数

JavaScript基础混乱

嗨,我想了解JavaScript的基本原理,并陷入一个条件.

    var foo = 1;
    function bar(){
        foo = 10;       
        return;
        function foo(){}
    }
    bar();
    alert(foo);
Run Code Online (Sandbox Code Playgroud)

在这里alert(foo),会给我1,并且我知道在return语句之后,函数foo()将不会执行.但是现在如果改变代码:

    var foo = 1;
    function bar(){
        foo = 10;       
        return;
    }
    bar();
    alert(foo); 
Run Code Online (Sandbox Code Playgroud)

在条形函数中,如果我将删除函数foo().然后alert(foo)会给我10

请帮忙,如果有人能解释我为什么?

javascript

4
推荐指数
2
解决办法
419
查看次数

标签 统计

javascript ×2

jasmine ×1

node.js ×1

protractor ×1