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. linux socket talkclient talkserver示例

    cleint: #define _GNU_SOURCE 1 #include <sys/types.h> #include <sys/socket.h> #include &l ...

  2. 在ASP.NET MVC中实现本地化和全球化

    在开发多语言网站时,我们可以为某种语言创建一个资源文件,根据浏览器所设置的不同语言偏好,让运行时选择具体使用哪个资源文件.资源文件在生成程序集的时候被嵌入到程序集. 本篇体验,在ASP.NET MVC ...

  3. 通过NTP协议进行时间同步

    最近发现手机的时间不是很准了,便到网上下了一个同步时间的小程序,简单了看了一下它的原理,是通过NTP协议来实现校时的,就顺便学习了一下NTP协议,用C#写了个简单的实现. NTP(Network Ti ...

  4. 【Devops】【docker】【CI/CD】2.docker启动jenkins环境+安装必要的插件

    [注意:]jenkins的docker镜像,需要从官网进入直接获取,其他地方获取到的docker镜像,可能因为Jenkins版本过低,导致后续插件安装失败等问题!!! ================ ...

  5. [开源]Google code Android开源项目(一)

    [Android分享] [开源]Google code Android开源项目(一) [复制链接]     449122717 2 主题 2 好友 816 积分 No.4 中级开发者 升级  19.3 ...

  6. jquery 图片文件转base64 显示

    <!DOCTYPE html> <html> <head> <meta name="viewport" content="wid ...

  7. Spring Framework 4.1.3 还是一样给力

    Spring Framework 4.1.3 发布,此版本是 4.1.x 系列的第三个维护版本,包括超过50 个 bug 修复和改进.本来是计划月末发布,但是想早些发布,配合这周要发布的 Spring ...

  8. java通过Stream对list集合分组

    java通过Stream对list集合分组 现在有一个List集合,想对该集合中的数据分组处理,想到java8中的stream,就搞来试试,非常给力!例子如下 1 2 3 4 5 6 7 8 9 10 ...

  9. anaconda、pip配置国内镜像

    一.anaconda配置镜像查看源:conda config --show-sources在Mac and Linux下:conda config --add channels https://mir ...

  10. ExtJS梦想之旅(八)--GridPanel和EditorGridPanel的使用

    表格在web开发中会经常被使用到,是一种非常重要的组件,因此ExtJS在这方面做得也很出色,在这里也作为一个重点的组件来和大家分享,共同探讨一下. Ext.grid.GridPanel此类系基于Gri ...