Skip to content

Commit

Permalink
[🔥AUDIT🔥] [fixwstesting] Remove the need for the jest wrappers (#872)
Browse files Browse the repository at this point in the history
🖍 _This is an audit!_ 🖍

## Summary:
Turned out importing `@jest/globals` was bad, and also unnecessary. It was causing jest to throw an error when I tried updating Wonder Blocks. This should fix that.

Issue: XXX-XXXX

## Test plan:
`yarn test` here and then I'll incorporate the updated release into Wonder Blocks and all should be well.

Author: somewhatabstract

Auditors: #frontend-infra-web, #frontend-infra

Required Reviewers:

Approved By:

Checks: ⌛ Lint, typecheck, and coverage check (ubuntu-latest, 16.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 16.x), ⌛ Analyze (javascript), ✅ gerald, ⏭  dependabot

Pull Request URL: #872
  • Loading branch information
somewhatabstract authored Aug 28, 2023
1 parent 275b5e0 commit d031421
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-crews-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/wonder-stuff-testing": patch
---

Fix Wonder Stuff Testing to work with jest again
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as JestWrappers from "../internal/jest-wrappers";

import {afterEachRestoreEnv} from "../after-each-restore-env";

jest.mock("../internal/jest-wrappers");
Expand Down Expand Up @@ -43,7 +41,7 @@ describe("#afterEachRestoreEnv", () => {
it("should register an afterEach callback", () => {
// Arrange
const afterEachSpy = jest
.spyOn(JestWrappers, "afterEach")
.spyOn(global, "afterEach")
.mockImplementationOnce(() => {});

// Act
Expand All @@ -57,7 +55,7 @@ describe("#afterEachRestoreEnv", () => {
it("should restore changed environment variables to their original values", () => {
// Arrange
const afterEachSpy = jest
.spyOn(JestWrappers, "afterEach")
.spyOn(global, "afterEach")
.mockImplementationOnce(() => {});

// Make sure the env vars exist.
Expand All @@ -82,7 +80,7 @@ describe("#afterEachRestoreEnv", () => {
it("should delete environment variables that were not set before", () => {
// Arrange
const afterEachSpy = jest
.spyOn(JestWrappers, "afterEach")
.spyOn(global, "afterEach")
.mockImplementationOnce(() => {});

// Make sure the env vars don't exist.
Expand All @@ -107,7 +105,7 @@ describe("#afterEachRestoreEnv", () => {
it("should only restore the variables it was asked to restore", () => {
// Arrange
const afterEachSpy = jest
.spyOn(JestWrappers, "afterEach")
.spyOn(global, "afterEach")
.mockImplementationOnce(() => {});

// Make sure the env vars don't exist or exist as we want.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {afterEach} from "./internal/jest-wrappers";

/**
* Restore the values of the given environment variables after each test.
*
Expand Down
10 changes: 0 additions & 10 deletions packages/wonder-stuff-testing/src/jest/internal/jest-wrappers.ts

This file was deleted.

0 comments on commit d031421

Please sign in to comment.