账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    jest 不输出descripbe和it的提示信息,什么情况
    84
    0

    问题描述

    launch.json

    {
      // Use IntelliSense to learn about possible attributes.
      // Hover to view descriptions of existing attributes.
      // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
      "version": "0.2.0",
      "configurations": [
        {
          "type": "node",
          "request": "launch",
          "name": "Launch Program",
          "program": "${workspaceRoot}/node_modules/jest/bin/jest",
          "port": 9229,
          "args": [
            // "${file}" // 入口文件
            "--watch"
          ],
          "runtimeArgs": [
            "--inspect-brk",
            // "${workspaceRoot}/node_modules/.bin/jest",
            // "--watch"
          ],
          "sourceMaps": true,
          "cwd": "${workspaceRoot}",
          "protocol": "inspector",
          "console": "integratedTerminal",
          "internalConsoleOptions": "neverOpen"
        }
      ]
    }

    测试文件

    let question1 = require('./question');
    describe('118 杨辉三角', () =>{
        it('1', () => {
            let res = question1(5);
            expect(res).toEqual([ [ 1 ], [ 1, 1 ], [ 1, 2, 1 ], [ 1, 3, 3, 1 ], [ 1, 4, 6, 4, 1 ] ]);
        });
        it('ddd', () => {
    
        })
    });

    输出

     PASS  src/index.test.js
     PASS  src/118/question.test.js
    
    Test Suites: 2 passed, 2 total
    Tests:       3 passed, 3 total
    Snapshots:   0 total
    Time:        1.567s
    Ran all test suites.

    怎么没有“118 杨辉三角”这样的字样呢,没搞定

    1
    打赏
    收藏
    点击回答
    您的回答被采纳后将获得:提问者悬赏的 10 元积分
        全部回答
    • 0
    • 我爱牛马 普通会员 1楼

      在Jest中,describe测试和it测试没有被强制显示为提示信息。这是因为describe测试用于测试函数、类或模块的行为,而it测试用于测试函数或类内部的特定方法。

      如果你看到describe测试或it测试的提示信息,可能是因为这些测试正在被其他的测试或测试用例覆盖。例如,如果你正在测试一个数组的长度,可能会看到一个类似的提示信息,比如"describe suite: expected length 10 but was 11"。

      如果你不希望这些测试显示提示信息,你可以通过在describe测试或it测试中添加一个断言来阻止这些提示信息的显示。例如:

      javascript describe('my test suite', () => { it('should return the expected length', () => { expect(myArray.length).toBe(10); }); });

      在这个例子中,如果没有看到描述测试或it测试的提示信息,那么这段代码就会正常工作。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部