feat: skip auto-cleanup via ATL_SKIP_AUTO_CLEANUP

ts
Jason Staten 5 years ago
parent caee065937
commit 79c6c4f2a5

@ -1,18 +1,18 @@
import React from 'react'
let render let render
beforeAll(() => { beforeAll(() => {
process.env.RTL_SKIP_AUTO_CLEANUP = 'true' process.env.ATL_SKIP_AUTO_CLEANUP = 'true'
const rtl = require('../') const atl = require('../')
render = rtl.render render = atl.render
}) })
// This one verifies that if RTL_SKIP_AUTO_CLEANUP is set // This one verifies that if ATL_SKIP_AUTO_CLEANUP is set
// then we DON'T auto-wire up the afterEach for folks // then we DON'T auto-wire up the afterEach for folks
test('first', () => { test('first', () => {
render(<div>hi</div>) render(`<div>hi</div>`)
}) })
test('second', () => { test('second', () => {
expect(document.body.innerHTML).toEqual('<div><div>hi</div></div>') expect(document.body.innerHTML).toEqual(
'<div><div class="ng-scope">hi</div></div>',
)
}) })

@ -1,11 +1,10 @@
import React from 'react'
import {render} from '../' import {render} from '../'
// This just verifies that by importing RTL in an // This just verifies that by importing ATL in an
// environment which supports afterEach (like jest) // environment which supports afterEach (like jest)
// we'll get automatic cleanup between tests. // we'll get automatic cleanup between tests.
test('first', () => { test('first', () => {
render(<div>hi</div>) render(`<div>hi</div>`)
}) })
test('second', () => { test('second', () => {

@ -5,8 +5,8 @@ import {cleanup} from './pure'
// then we'll automatically run cleanup afterEach test // then we'll automatically run cleanup afterEach test
// this ensures that tests run in isolation from each other // this ensures that tests run in isolation from each other
// if you don't like this then either import the `pure` module // if you don't like this then either import the `pure` module
// or set the RTL_SKIP_AUTO_CLEANUP env variable to 'true'. // or set the ATL_SKIP_AUTO_CLEANUP env variable to 'true'.
if (typeof afterEach === 'function' && !process.env.RTL_SKIP_AUTO_CLEANUP) { if (typeof afterEach === 'function' && !process.env.ATL_SKIP_AUTO_CLEANUP) {
afterEach(async () => { afterEach(async () => {
await flush() await flush()
cleanup() cleanup()

Loading…
Cancel
Save