Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: atob is not defined #12268

Closed
aduh95 opened this issue Jan 27, 2022 · 1 comment · Fixed by #12269
Closed

[Bug]: atob is not defined #12268

aduh95 opened this issue Jan 27, 2022 · 1 comment · Fixed by #12269

Comments

@aduh95
Copy link
Contributor

aduh95 commented Jan 27, 2022

Version

27.4.7

Steps to reproduce

mkdir jestRepro
cd jestRepro 
npm i jest
mkdir test
echo 'it("should decode base64",()=>expect(atob("MA==")).toBe("0"))' > test/atob.test.js
npx jest

Expected behavior

Same as with --env=jsdom:

 PASS  test/atob.test.js
  ✓ should decode base64 (2 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        0.972 s, estimated 1 s
Ran all test suites.

Actual behavior

 FAIL  test/atob.test.js
  ✕ should decode base64 (1 ms)

  ● should encode to base64

    ReferenceError: atob is not defined

    > 1 | it("should encode to base64",()=>expect(atob("MA==")).toBe("0"))
        | ^
      2 |

      at Object.<anonymous> (test/atob.test.js:1:1)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        0.261 s, estimated 1 s
Ran all test suites.

Additional context

atob and btoa are available as globals since Node.js 16.0.0, I think Jest should leave them available as well.

Environment

System:
    OS: macOS 12.0.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Binaries:
    Node: 17.4.0 - /usr/local/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.3.1 - /usr/local/bin/npm
  npmPackages:
    jest: ^27.4.7 => 27.4.7
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant