javascript - 为什么茉莉花不运行测试?
问题描述
我刚刚开始学习 jasmine 来测试 JavaScript,对于我的生活,我无法弄清楚为什么 Jasmine 会运行我的布尔测试而不是我的数学函数测试。注意,我使用 index.html 来运行测试,我没有 specrunner.html,尽管我确实有 jasmine 依赖项。这个答案必须很简单。我显然错过了一些东西。
Jasmine 结果- 2 个规范中的 1 个 - 运行所有 1 个规范,0 次失败,随机使用种子 86651
function getOpposite(bool) {
return !bool;
}
function add(x, y) {
return x + y;
}
describe('math function, addition', () => {
it('return sum of 2 numbers', () => { //this does not work
const num1 = 2;
const num2 = 3;
const result = add(num1, num2);
expect(result).toBe(5);
})
});
describe('boolean test', () => {
it('expect value of true', () => { // this works
let bool = false;
const result = getOpposite(bool);
expect(result).toBe(true);
})
});
解决方案
推荐阅读
- html - 有条件地在 R-markdown 中嵌入视频(bookdown)
- python-telegram-bot - 如何从 chat_id 中检索用户名?
- java - 对包含自定义对象的 ArrayList 进行排序
- docker - Flink 消费者作业无法从 Docker 连接到 Kafka
- virtual-machine - 有两个带 NAT 但与主机 IP 不同的 VirtualBox 虚拟机?
- python - 使用 python 在特定位置读取文本
- ios - 未找到 -lPods- 的 XCode 库
- javascript - 提交表单后清除formik错误
- javascript - 发送到视图的模型无法在 ajax get 中读取
- reactjs - React Material UI 单选按钮看起来杂乱无章