From 79c6c4f2a53b4f49b1143e1f7295520ec1a229c1 Mon Sep 17 00:00:00 2001 From: Jason Staten Date: Fri, 1 Nov 2019 21:10:04 -0600 Subject: [PATCH] feat: skip auto-cleanup via ATL_SKIP_AUTO_CLEANUP --- src/__tests__/auto-cleanup-skip.js | 16 ++++++++-------- src/__tests__/auto-cleanup.js | 5 ++--- src/index.js | 4 ++-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/__tests__/auto-cleanup-skip.js b/src/__tests__/auto-cleanup-skip.js index e5ef35a..9c1963e 100644 --- a/src/__tests__/auto-cleanup-skip.js +++ b/src/__tests__/auto-cleanup-skip.js @@ -1,18 +1,18 @@ -import React from 'react' - let render beforeAll(() => { - process.env.RTL_SKIP_AUTO_CLEANUP = 'true' - const rtl = require('../') - render = rtl.render + process.env.ATL_SKIP_AUTO_CLEANUP = 'true' + const atl = require('../') + 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 test('first', () => { - render(
hi
) + render(`
hi
`) }) test('second', () => { - expect(document.body.innerHTML).toEqual('
hi
') + expect(document.body.innerHTML).toEqual( + '
hi
', + ) }) diff --git a/src/__tests__/auto-cleanup.js b/src/__tests__/auto-cleanup.js index 1d0a795..d700a96 100644 --- a/src/__tests__/auto-cleanup.js +++ b/src/__tests__/auto-cleanup.js @@ -1,11 +1,10 @@ -import React from 'react' 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) // we'll get automatic cleanup between tests. test('first', () => { - render(
hi
) + render(`
hi
`) }) test('second', () => { diff --git a/src/index.js b/src/index.js index 5e94267..8755c02 100644 --- a/src/index.js +++ b/src/index.js @@ -5,8 +5,8 @@ import {cleanup} from './pure' // then we'll automatically run cleanup afterEach test // this ensures that tests run in isolation from each other // if you don't like this then either import the `pure` module -// or set the RTL_SKIP_AUTO_CLEANUP env variable to 'true'. -if (typeof afterEach === 'function' && !process.env.RTL_SKIP_AUTO_CLEANUP) { +// or set the ATL_SKIP_AUTO_CLEANUP env variable to 'true'. +if (typeof afterEach === 'function' && !process.env.ATL_SKIP_AUTO_CLEANUP) { afterEach(async () => { await flush() cleanup()