当前位置:网站首页>jest test, component test
jest test, component test
2022-08-02 15:22:00 【N.S.N】
Jest Can help you achieve painless JavaScript 单元测试支持,由 Facebook 推出.
使用命令行 npx jest 文件进行测试
test('test common matcher', () => {
expect( 2 + 2 ).toBe(4)// 判断2+2是否等于4
expect( 2 + 3 ).not.toBe(4)
})
test('test to betrue or false', () => {
expect(1).toBeTruthy()//判断1是否为真
expect(0).toBeFalsy()
})
test('test number', () => {
expect(4).toBeGreaterThan(3) // 4是否比3大
expect(2).toBeLessThan(3) // 2是否比3小
})
test('test object', () => {
expect({
name: 'roadsign'}).toEqual({
name: 'roadsign'})
})
组件进行测试
Test cases must use the command linenpm test ,否则容易报错
import React from 'react';
import {
render } from '@testing-library/react';
import Button from './button';
test('our first react test case', () => {
const wrapper = render(<Button>nice</Button>);
const element = wrapper.queryByText('nice');
expect(element).toBeInTheDocument();
});
边栏推荐
猜你喜欢

Win10系统设置application identity自动提示拒绝访问怎么办

将SSE指令转换为ARM NEON指令

基于GPT的隐变量表征解码结构

【使用Pytorch实现ResNet网络模型:ResNet50、ResNet101和ResNet152】

Win7怎么干净启动?如何只加载基本服务启动Win7系统

PyTorch⑩---卷积神经网络_一个小的神经网络搭建

Win11 computer off for a period of time without operating network how to solve

基于无监督医学图像配准论文(1)

深度学习之文本分类总结

PyTorch①---加载数据、tensorboard的使用
随机推荐
Bash shell位置参数
机器学习和深度学习中的梯度下降及其类型
系统线性、时不变、因果判断
使用npx -p @storybook/cli sb init安装失败,手把手搭建专属的storybook
ECP2459耐压60V降压BUCK电路用于WIFI模块供电方案原理图
GICv3/v4-软件概述
How to add a one-key shutdown option to the right-click menu in Windows 11
PyTorch④---DataLoader的使用
win10 system update error code 0x80244022 how to do
针对多轮推理分类问题的软标签构造方法
关于c语言的调试技巧
SQL的通用语法和使用说明(图文)
设备驱动框架简介
Makefile容易犯错的语法
FP7195转模拟恒流调光芯片在机器视觉光源的应用优势
LLVM系列第七章:函数参数Function Arguments
内存申请(malloc)和释放(free)之下篇
Win10安装了固态硬盘还是有明显卡顿怎么办?
投资组合理论的简单介绍
2021-10-14