Comments (5)
You're trying to run vm
inside of vm
, which is not really supported. Why do you need to do that?
from jest.
when we are doing vm.createContext(global), we are not able to access window in the js files, even though we have injected window into context
from jest.
You're trying to run
vm
inside ofvm
, which is not really supported. Why do you need to do that?
Im working on a legacy js project, we don't have export and import. so we are using vm.createcontext
to inject some js files globally before all tests runs, especially some class
.
Is there any better approach to do this.
Also what do you mean by vm inside vm ?
from jest.
inject some js files globally before all tests runs, especially some class.
Is there any better approach to do this.
https://jestjs.io/docs/configuration#setupfiles-array should do what you want.
Also what do you mean by vm inside vm ?
Jest already runs all tests within separate vm contexts
from jest.
inject some js files globally before all tests runs, especially some class.
Is there any better approach to do this.https://jestjs.io/docs/configuration#setupfiles-array should do what you want.
Also what do you mean by vm inside vm ?
Jest already runs all tests within separate vm contexts
Still we need to inject the class and singletons to the global object right ?. since we don't have exports and imports
for example
var myVar = {};
myVar.getName = function(){
return 'rahul mr'
}
it('hello this is my test', () => {
console.log('hello', myVar.getName());
})
For this to work , we are required to run vm.runincontext()
with global as context
from jest.
Related Issues (20)
- No tests found on Windows if any folder in path starts with special character HOT 3
- [Bug]: Unable to run multiple tests through -t argument HOT 4
- [Bug]: `constructorA.mock.instances` not correct when using `jest.fn().mockImplementation(() => ({ ... }))` HOT 2
- Jest needs disclaimers. HOT 1
- Document release process
- [Bug]: Jest fails to serialize custom elements with anonymous constructors
- [Bug]: Critical security finding in jest-reporters HOT 2
- [Bug]: Incorrect Error Stacktrace when using Object.freeze(Object.prototype) HOT 1
- [Bug]: when adding "disctributed" to a testfile name it no longer runs
- [Bug]: global object is not usable in globalTearDown file
- Top-level 'await' expressions not working even if tried a lot of solutions found in StackOverflow HOT 1
- [Feature]: Upgrade jest-environment-jsdom from v22 to v24 to avoid deprecated punycode warning HOT 4
- [Docs]: `react-test-renderer` deprecated HOT 3
- [Feature]: Support Babel v8 HOT 1
- [Bug]: `transform` does not accept `file:` urls HOT 2
- [Feature]: babel-jest: opting out babel-preset-jest
- [Docs]: Update jest.restoreAllMocks behavior change HOT 1
- [Bug]: @jest/create-cache-key-function does not have correct type definition
- Import, export syntax error from @azure/storage-blob in nx monorepo HOT 1
- [Bug]: When executing the command npm install jest, a warning occurs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jest.