question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReferenceError: document is not defined

See original GitHub issue

How can I run vscode-jest to include document as global?

It works with npm run ./bin/test.js

//./bin/test.js
process.env.NODE_ENV = 'test';
process.env.PUBLIC_URL = '';

// Load environment variables from .env file. Suppress warnings using silent
// if this file is missing. dotenv will never modify any environment variables
// that have already been set.
// https://github.com/motdotla/dotenv
require('dotenv').config({
    silent: true
});

const jest = require('jest');
const argv = process.argv.slice(2);

// Watch unless on CI
if (!process.env.CI) {
    argv.push('--watch');
}

argv.push('--no-cache');

jest.run(argv);

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ortacommented, Nov 28, 2016

this project runs: jest --json --useStderr --watch --colors false --jsonOuputFile /tmp/vscode-jest.json in the root project, in my projects it does use the settings from my Package.json

Other than that, we do nothing unique to the jest configuration in the project, can you run the above command normally? ^

0reactions
Altianocommented, May 28, 2017

sorry, turns out it is already declared in package.json.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix ReferenceError: Document is not defined ... - Sabe.io
The most common reason for getting the reference error while on the browser is when you try to access the document object too...
Read more >
ReferenceError: document is not defined in JavaScript
The "ReferenceError: document is not defined" error occurs for multiple reasons: ... The document relates to the document object which represents a web...
Read more >
ReferenceError: document is not defined (in plain JavaScript)
Explanation: The error is caused because NextJs renders the page in the server only and in the server document (document is used inside...
Read more >
How To Fix ReferenceError document is not defined ... - Isotropic
If you are trying to use the document object and receiving a ReferenceError: document is not defined error then there is a good...
Read more >
How to solve the document is not defined error - Flavio Copes
Here's how to fix the “referenceerror: document is not defined” error that you might have in Node.js or with a tool like Next.js....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found