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. IDA .edata .rdata .idata .text segments

    .rdata is for const data. It is the read only version of the .data segment. .idata holds the import ...

  2. ARM Memory Copy

    MODULE ARM_MEMORY PUBLIC ARM_MEMCPY PUBLIC ARM_MEMSET PUBLIC ARM_MEMSET8 PUBLIC ARM_MEMSET16 PUBLIC ...

  3. securecrt中文乱码以及ubuntu设置locale

    参考文献 http://wiki.ubuntu.org.cn/%E4%BF%AE%E6%94%B9locale http://www.bootf.com/547.html 强烈建议 ubuntu下面不 ...

  4. 打印函数 lodop

    Lodop属性和方法详解 例子:LODOP.PRINT_INIT("打印任务名");LODOP.SET_PRINT_COPIES(2);bdhtml=window.document ...

  5. JS实现各种复制到剪贴板

    一.实现点击按钮,复制文本框中的的内容                         <script type="text/javascript"> function ...

  6. android studio# jdk8# class file for java.lang.invoke.MethodType not found

    https://github.com/evant/gradle-retrolambda/issues/23 class file for java.lang.invoke.MethodType not ...

  7. 猫都能学会的Unity3D Shader入门指南(二)

    关于本系列 这是Unity3D Shader入门指南系列的第二篇,本系列面向的对象是新接触Shader开发的Unity3D使用者,因为我本身自己也是Shader初学者,因此可能会存在错误或者疏漏,如果 ...

  8. 黑吃黑第四季/全集Banshee迅雷下载

    英文全名Banshee,第5季(2015)Cinemax. 本季看点:<黑吃黑>Ana Ayora加盟第四季,将会饰演Nina Cruz,表面上是在镇里一个聪明而又强悍的新副警长,但实际是 ...

  9. 在EditText中添加QQ表情

    本文参考自:http://blog.csdn.net/wulianghuan/article/details/8583921 在输入框中输入表情是每个聊天软件的必备功能,做到这点仅需要将表情放入工程图 ...

  10. information_schema系列十

    information_schema系列十   1:INNODB_FT_CONFIG 这张表存的是全文索引的信息,查询前可以先通过以下语句查询一下开启全文索引的表: show variables li ...