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

fix: expose vm context directly from test envs #9428

Merged
merged 5 commits into from Jan 21, 2020

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Jan 19, 2020

Summary

I've been looking into ES Modules and what it'd take, and one thing is passing in a context when constructing it (see https://nodejs.org/api/vm.html#vm_class_vm_module). Since I've just added compileFunction next to runScript adding yet another function seemed silly. So I've removed compileFunction (never released anyways) and added a method which exposes the raw vm.Context. This matches what JSDOM has done (which I suppose is the motivation for the original runScript implementation - JSDOM previously only had runVMScript()), see jsdom/jsdom#2768. Note that we cannot upgrade to JSDOM@16 yet since they've dropped support for Node 8. I've created https://www.npmjs.com/package/jest-environment-jsdom-sixteen though (which currently has compileFunction - I'll change to getVmContext shortly).

Relates to #9252.

Test plan

Green CI

@codecov-io
Copy link

Codecov Report

Merging #9428 into master will decrease coverage by 0.01%.
The diff coverage is 28.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9428      +/-   ##
==========================================
- Coverage   65.04%   65.03%   -0.02%     
==========================================
  Files         283      283              
  Lines       12088    12093       +5     
  Branches     2983     2984       +1     
==========================================
+ Hits         7863     7865       +2     
- Misses       3589     3591       +2     
- Partials      636      637       +1
Impacted Files Coverage Δ
packages/jest-runner/src/runTest.ts 2.19% <ø> (ø) ⬆️
packages/jest-environment-node/src/index.ts 56.41% <0%> (+5.24%) ⬆️
packages/jest-runtime/src/index.ts 64.5% <30.76%> (-0.94%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ece4f9...0f52b41. Read the comment docs.

@SimenB SimenB mentioned this pull request Jan 19, 2020
21 tasks
@SimenB
Copy link
Member Author

SimenB commented Jan 21, 2020

#9431 (comment) ditto

@github-actions
Copy link

This pull request 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 May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants