For some React component testing, we have common setup in each test file:

import { render } from 'react-testing-library'
import 'jest-dom/extend-expect'
import 'react-testing-library/cleanup-after-each'

We want to setup a common place for JEST to load those scripts:

// jest.config.js

module.exports = {
setupTestFrameworkScriptFile: '<rootDir>/testSetup.js'
}
// testSetup.js

import 'jest-dom/extend-expect'
import 'react-testing-library/cleanup-after-each'

Then for component test file, we can remove those two lines.

[Jest] Set up Testing Globals in an Application with Jest的更多相关文章

  1. [React] Use Jest's Snapshot Testing Feature

    Often when testing, you use the actual result to create your assertion and have to manually update i ...

  2. [JavaEE] Testing the Java EE Application : Basic Arquillian integration test

    We have model like this: package com.pluralsight.bookstore.model; import javax.persistence.*; import ...

  3. [Testing] Config jest to test Javascript Application -- Part 3

    Run Jest Watch Mode by default locally with is-ci-cli In CI, we don’t want to start the tests in wat ...

  4. [Testing] Config jest to test Javascript Application -- Part 2

    Setup an afterEach Test Hook for all tests with Jest setupTestFrameworkScriptFile With our current t ...

  5. [Testing] Config jest to test Javascript Application -- Part 1

    Transpile Modules with Babel in Jest Tests Jest automatically loads and applies our babel configurat ...

  6. spring boot application.properties 属性详解

    2019年3月21日17:09:59 英文原版: https://docs.spring.io/spring-boot/docs/current/reference/html/common-appli ...

  7. Spring boot 全局配置文件application.properties

    #更改Tomcat端口号 server.port=8090 #修改进入DispatcherServlet的规则为:*.htmlserver.servlet-path=*.html#这里要注意高版本的s ...

  8. 【springboot】之Application配置

    # =================================================================== # COMMON SPRING BOOT PROPERTIE ...

  9. springboot成神之——application.properties所有可用属性

    application.properties所有可用属性 # =================================================================== # ...

随机推荐

  1. Training JTAG Interface

    For most embedded CPU architecture implementations, the JTAG port is used by the debugger to interfa ...

  2. Delph 两个对立程序使用消息进行控制通信

    在实际应用中,总是会遇到两个独立的程序进行通信,其实通信的方式有好几种,比如进程间通信,消息通信. 项目中用到了此功能, 此功能用于锁屏程序, 下面把实现的流程和大家分享一下. 1. 在锁屏程序中,自 ...

  3. Unity3D实践系列06,球体撞击物体游戏

    本篇实现一个球体在固定区域移动撞击Cube的游戏. 首先有1个Plane当作地面,1个Sphere当作球体,4个Cube当作墙,12个Cube当作被撞击物体,另外还有球体的撞击计算,在撞击的过程适时显 ...

  4. (转)Java中的守护线程

    Java的守护线程与非守护线程   守护线程与非守护线程 最近在看多线程的Timer章节,发现运用到了守护线程,感觉Java的基础知识还是需要补充. Java分为两种线程:用户线程和守护线程 所谓守护 ...

  5. sqlite 截取字符串函数substr

    函数:substr(string string,num start,num length) 用法: string为字符串: start为起始位置:字符串的第一个字符的位置为1,不是从0开始计算 len ...

  6. C#编程(四十五)----------格式字符串

    格式字符串 1.格式化货币(跟系统的环境有关,中文系统默认格式化人民币,英文系统格式化美元) 案例: string str=string.Format("{0:C}",0.2); ...

  7. winform 给textbox 增加 或 减小字体大小 z

    private void btnAddFont_Click(object sender, EventArgs e) { float fSize = this.txtResult.Font.Size; ...

  8. python测试开发django-35.xadmin注册表信息

    前言 xadmin后台如果要对表的内容增删改查,跟之前的admin.py文件里面写注册表信息一样,需在admin.py同一级目录新建一个adminx.py的文件. 然后在adminx.py文件控制页面 ...

  9. XCode的The argument is invalid

      google查了一下,没找到解决的方法.有一篇blog应该有写怎么解决,可惜是wordpress.com的站点,打不开,网页快照也看不了-   后来回忆了一下操作步骤,只是添加了cocos2dx的 ...

  10. Android 代码实现应用强制装到手机内存

    在Froyo(android 2.2,API Level:8)中引入了android:installLocation.通过设置该属性可以使得开发者以及用户决定程序的安装位置. android:inst ...