krr*_*hna 5 javascript node.js jasmine protractor
在 VSCode 中的 node.js 项目中,我尝试在运行规范之前读取配置信息。但我的规范总是在“beforeAll”块之前首先执行。
\n\nbeforeAll(() => {\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\nRun Code Online (Sandbox Code Playgroud)\n\n我尝试简化代码以仅保留一个期望语句,但它仍然是相同的。
\n\n我得到的当前输出是 Step 2 、 Step 0 、 Step 1
\n\n我期待的是步骤 0、步骤 1、步骤 2
\n根据 jasmine 文档,生成的输出是正确的。IT块中的代码只有在beforeAll完成后才会被执行。但是,如果 beforeAll 有任何 Promise,那么我们需要传递 did 关键字,使执行等待 beforeAll 异步操作完成,然后再执行 IT 块。
| 归档时间: |
|
| 查看次数: |
1965 次 |
| 最近记录: |