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

Remove access to Buffer in @edge-runtime/jest-environment #953

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/beige-tomatoes-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@edge-runtime/jest-environment': major
---

Disallow access to `Buffer`
1 change: 0 additions & 1 deletion packages/jest-environment/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class EdgeEnvironment implements JestEnvironment<number> {
const vm = new EdgeVM({
extend: (context) => {
context.global = context
context.Buffer = Buffer
return context
},
...((config as any).projectConfig ?? config)?.testEnvironmentOptions,
Expand Down
4 changes: 4 additions & 0 deletions packages/jest-environment/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ test('allows to run crypto', async () => {
test('has EdgeRuntime global', () => {
expect(EdgeRuntime).toEqual('edge-runtime')
})

test('does not have access to node global variables', () => {
expect(typeof Buffer).toEqual('undefined')
})
Loading