ReferenceError: Phaser is not defined (Running test with Mocha)
up vote
0
down vote
favorite
I try to test my javascript application with Phaser 3, Mocha and NodeJS.
And if i run the test command "npm test" I get the following error:
How can i fix this?
This is the error message which i get everytime:
(function (exports, require, module, __filename, __dirname) { import phaser from 'phaser';
^^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (C:UsersChrisDocumentsGitHubgamejam-challenge-nov18testappTest.js:2:23)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesmochalibmocha.js:250:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesmochalibmocha.js:247:14)
at Mocha.run (C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesmochalibmocha.js:576:10)
at Object.<anonymous> (C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesmochabin_mocha:637:18)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
npm ERR! Test failed. See above for more details.
This is the test I wrote (using Mocha):
// appTest.js
var assert = require('chai').assert;
const isRowFreeFunc = require('../app').isRowFree;
describe('function', function(){
it('should be free', function(){
gameField = [
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1]
];
var result = isRowFreeFunc(6);
assert.equal(result, true);
})
});
This is my nodejs configuration:
// package.json
{
"name": "testing101",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "parcel index.html",
"test": "mocha"
},
"keywords": ,
"author": "",
"license": "ISC",
"devDependencies": {
"babel-preset-env": "^1.6.1",
"jest": "^22.4.4",
"parcel-bundler": "^1.7.0",
"phaser": "^3.15.1"
},
"jest": {
"verbose": true,
"testURL": "http://localhost:1234/"
},
"dependencies": {
"phaser": "^3.1.0",
"mocha": "^5.2.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/kippenvogel/gamejam-challenge-nov18.git"
},
"bugs": {
"url": "https://github.com/kippenvogel/gamejam-challenge-nov18/issues"
},
"homepage": "https://github.com/kippenvogel/gamejam-challenge-nov18#readme"
}
This is a part of my Application (reduced):
// app.js
import phaser from 'phaser';
var config = {
type: Phaser.AUTO,
width: 900,
height: 800,
scene: {
preload: preload,
create: create,
update: update
}
};
// IS ROW FREE OR FULL
/***
*
* @returns {boolean}
* true = free
* false = full
*/
module.exports = {
isRowFree: function(row) {
// ROW IS FULL
if (gameField[0][row] == 1 ||
gameField[0][row] == 2){
console.log(gameField);
console.log("ROW (" + row + ") is full!");
return false;
}
// ROW IS FREE
else {
var hh = getHeigthOfColumn(row);
console.log ("Free Stones: " + hh);
return true;
}
}
}
function getHeigthOfColumn(column){
var stones = 5;
for (stones; stones >= 0; stones = stones-1){
// FREE FOR MIN. 1 STONE
if (gameField[stones][column] == 0){
break;
}
if (gameField[stones][column] == 1 || gameField[stones][column] == 2 ){
}
}
console.log( "Free Stones in Column(" + column+"): " + stones);
return stones;
}
javascript html node.js mocha phaser-framework
add a comment |
up vote
0
down vote
favorite
I try to test my javascript application with Phaser 3, Mocha and NodeJS.
And if i run the test command "npm test" I get the following error:
How can i fix this?
This is the error message which i get everytime:
(function (exports, require, module, __filename, __dirname) { import phaser from 'phaser';
^^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (C:UsersChrisDocumentsGitHubgamejam-challenge-nov18testappTest.js:2:23)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesmochalibmocha.js:250:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesmochalibmocha.js:247:14)
at Mocha.run (C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesmochalibmocha.js:576:10)
at Object.<anonymous> (C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesmochabin_mocha:637:18)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
npm ERR! Test failed. See above for more details.
This is the test I wrote (using Mocha):
// appTest.js
var assert = require('chai').assert;
const isRowFreeFunc = require('../app').isRowFree;
describe('function', function(){
it('should be free', function(){
gameField = [
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1]
];
var result = isRowFreeFunc(6);
assert.equal(result, true);
})
});
This is my nodejs configuration:
// package.json
{
"name": "testing101",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "parcel index.html",
"test": "mocha"
},
"keywords": ,
"author": "",
"license": "ISC",
"devDependencies": {
"babel-preset-env": "^1.6.1",
"jest": "^22.4.4",
"parcel-bundler": "^1.7.0",
"phaser": "^3.15.1"
},
"jest": {
"verbose": true,
"testURL": "http://localhost:1234/"
},
"dependencies": {
"phaser": "^3.1.0",
"mocha": "^5.2.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/kippenvogel/gamejam-challenge-nov18.git"
},
"bugs": {
"url": "https://github.com/kippenvogel/gamejam-challenge-nov18/issues"
},
"homepage": "https://github.com/kippenvogel/gamejam-challenge-nov18#readme"
}
This is a part of my Application (reduced):
// app.js
import phaser from 'phaser';
var config = {
type: Phaser.AUTO,
width: 900,
height: 800,
scene: {
preload: preload,
create: create,
update: update
}
};
// IS ROW FREE OR FULL
/***
*
* @returns {boolean}
* true = free
* false = full
*/
module.exports = {
isRowFree: function(row) {
// ROW IS FULL
if (gameField[0][row] == 1 ||
gameField[0][row] == 2){
console.log(gameField);
console.log("ROW (" + row + ") is full!");
return false;
}
// ROW IS FREE
else {
var hh = getHeigthOfColumn(row);
console.log ("Free Stones: " + hh);
return true;
}
}
}
function getHeigthOfColumn(column){
var stones = 5;
for (stones; stones >= 0; stones = stones-1){
// FREE FOR MIN. 1 STONE
if (gameField[stones][column] == 0){
break;
}
if (gameField[stones][column] == 1 || gameField[stones][column] == 2 ){
}
}
console.log( "Free Stones in Column(" + column+"): " + stones);
return stones;
}
javascript html node.js mocha phaser-framework
You either need to compile your code with babel or userequire
instead of import.
– lependu
Nov 11 at 15:11
I did add "var express = require('phaser');" to app.js. Now I get this error: C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesphasersrcpolyfillsAudioContextMonkeyPatch.js:60 if (window.hasOwnProperty('webkitAudioContext') && ^ ReferenceError: window is not defined
– CodeDude
Nov 11 at 15:23
nodejs does not provide DOM by default. You need to use something like jsdom to run your code against a specific DOM tree.
– lependu
Nov 11 at 15:29
How can i do this? I installed JSDOM and added 'const jsdom = require('jsdom') const { JSDOM } = jsdom;' in the test.js
– CodeDude
Nov 11 at 15:48
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I try to test my javascript application with Phaser 3, Mocha and NodeJS.
And if i run the test command "npm test" I get the following error:
How can i fix this?
This is the error message which i get everytime:
(function (exports, require, module, __filename, __dirname) { import phaser from 'phaser';
^^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (C:UsersChrisDocumentsGitHubgamejam-challenge-nov18testappTest.js:2:23)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesmochalibmocha.js:250:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesmochalibmocha.js:247:14)
at Mocha.run (C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesmochalibmocha.js:576:10)
at Object.<anonymous> (C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesmochabin_mocha:637:18)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
npm ERR! Test failed. See above for more details.
This is the test I wrote (using Mocha):
// appTest.js
var assert = require('chai').assert;
const isRowFreeFunc = require('../app').isRowFree;
describe('function', function(){
it('should be free', function(){
gameField = [
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1]
];
var result = isRowFreeFunc(6);
assert.equal(result, true);
})
});
This is my nodejs configuration:
// package.json
{
"name": "testing101",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "parcel index.html",
"test": "mocha"
},
"keywords": ,
"author": "",
"license": "ISC",
"devDependencies": {
"babel-preset-env": "^1.6.1",
"jest": "^22.4.4",
"parcel-bundler": "^1.7.0",
"phaser": "^3.15.1"
},
"jest": {
"verbose": true,
"testURL": "http://localhost:1234/"
},
"dependencies": {
"phaser": "^3.1.0",
"mocha": "^5.2.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/kippenvogel/gamejam-challenge-nov18.git"
},
"bugs": {
"url": "https://github.com/kippenvogel/gamejam-challenge-nov18/issues"
},
"homepage": "https://github.com/kippenvogel/gamejam-challenge-nov18#readme"
}
This is a part of my Application (reduced):
// app.js
import phaser from 'phaser';
var config = {
type: Phaser.AUTO,
width: 900,
height: 800,
scene: {
preload: preload,
create: create,
update: update
}
};
// IS ROW FREE OR FULL
/***
*
* @returns {boolean}
* true = free
* false = full
*/
module.exports = {
isRowFree: function(row) {
// ROW IS FULL
if (gameField[0][row] == 1 ||
gameField[0][row] == 2){
console.log(gameField);
console.log("ROW (" + row + ") is full!");
return false;
}
// ROW IS FREE
else {
var hh = getHeigthOfColumn(row);
console.log ("Free Stones: " + hh);
return true;
}
}
}
function getHeigthOfColumn(column){
var stones = 5;
for (stones; stones >= 0; stones = stones-1){
// FREE FOR MIN. 1 STONE
if (gameField[stones][column] == 0){
break;
}
if (gameField[stones][column] == 1 || gameField[stones][column] == 2 ){
}
}
console.log( "Free Stones in Column(" + column+"): " + stones);
return stones;
}
javascript html node.js mocha phaser-framework
I try to test my javascript application with Phaser 3, Mocha and NodeJS.
And if i run the test command "npm test" I get the following error:
How can i fix this?
This is the error message which i get everytime:
(function (exports, require, module, __filename, __dirname) { import phaser from 'phaser';
^^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (C:UsersChrisDocumentsGitHubgamejam-challenge-nov18testappTest.js:2:23)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesmochalibmocha.js:250:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesmochalibmocha.js:247:14)
at Mocha.run (C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesmochalibmocha.js:576:10)
at Object.<anonymous> (C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesmochabin_mocha:637:18)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
npm ERR! Test failed. See above for more details.
This is the test I wrote (using Mocha):
// appTest.js
var assert = require('chai').assert;
const isRowFreeFunc = require('../app').isRowFree;
describe('function', function(){
it('should be free', function(){
gameField = [
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 1]
];
var result = isRowFreeFunc(6);
assert.equal(result, true);
})
});
This is my nodejs configuration:
// package.json
{
"name": "testing101",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "parcel index.html",
"test": "mocha"
},
"keywords": ,
"author": "",
"license": "ISC",
"devDependencies": {
"babel-preset-env": "^1.6.1",
"jest": "^22.4.4",
"parcel-bundler": "^1.7.0",
"phaser": "^3.15.1"
},
"jest": {
"verbose": true,
"testURL": "http://localhost:1234/"
},
"dependencies": {
"phaser": "^3.1.0",
"mocha": "^5.2.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/kippenvogel/gamejam-challenge-nov18.git"
},
"bugs": {
"url": "https://github.com/kippenvogel/gamejam-challenge-nov18/issues"
},
"homepage": "https://github.com/kippenvogel/gamejam-challenge-nov18#readme"
}
This is a part of my Application (reduced):
// app.js
import phaser from 'phaser';
var config = {
type: Phaser.AUTO,
width: 900,
height: 800,
scene: {
preload: preload,
create: create,
update: update
}
};
// IS ROW FREE OR FULL
/***
*
* @returns {boolean}
* true = free
* false = full
*/
module.exports = {
isRowFree: function(row) {
// ROW IS FULL
if (gameField[0][row] == 1 ||
gameField[0][row] == 2){
console.log(gameField);
console.log("ROW (" + row + ") is full!");
return false;
}
// ROW IS FREE
else {
var hh = getHeigthOfColumn(row);
console.log ("Free Stones: " + hh);
return true;
}
}
}
function getHeigthOfColumn(column){
var stones = 5;
for (stones; stones >= 0; stones = stones-1){
// FREE FOR MIN. 1 STONE
if (gameField[stones][column] == 0){
break;
}
if (gameField[stones][column] == 1 || gameField[stones][column] == 2 ){
}
}
console.log( "Free Stones in Column(" + column+"): " + stones);
return stones;
}
javascript html node.js mocha phaser-framework
javascript html node.js mocha phaser-framework
asked Nov 11 at 14:57
CodeDude
11
11
You either need to compile your code with babel or userequire
instead of import.
– lependu
Nov 11 at 15:11
I did add "var express = require('phaser');" to app.js. Now I get this error: C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesphasersrcpolyfillsAudioContextMonkeyPatch.js:60 if (window.hasOwnProperty('webkitAudioContext') && ^ ReferenceError: window is not defined
– CodeDude
Nov 11 at 15:23
nodejs does not provide DOM by default. You need to use something like jsdom to run your code against a specific DOM tree.
– lependu
Nov 11 at 15:29
How can i do this? I installed JSDOM and added 'const jsdom = require('jsdom') const { JSDOM } = jsdom;' in the test.js
– CodeDude
Nov 11 at 15:48
add a comment |
You either need to compile your code with babel or userequire
instead of import.
– lependu
Nov 11 at 15:11
I did add "var express = require('phaser');" to app.js. Now I get this error: C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesphasersrcpolyfillsAudioContextMonkeyPatch.js:60 if (window.hasOwnProperty('webkitAudioContext') && ^ ReferenceError: window is not defined
– CodeDude
Nov 11 at 15:23
nodejs does not provide DOM by default. You need to use something like jsdom to run your code against a specific DOM tree.
– lependu
Nov 11 at 15:29
How can i do this? I installed JSDOM and added 'const jsdom = require('jsdom') const { JSDOM } = jsdom;' in the test.js
– CodeDude
Nov 11 at 15:48
You either need to compile your code with babel or use
require
instead of import.– lependu
Nov 11 at 15:11
You either need to compile your code with babel or use
require
instead of import.– lependu
Nov 11 at 15:11
I did add "var express = require('phaser');" to app.js. Now I get this error: C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesphasersrcpolyfillsAudioContextMonkeyPatch.js:60 if (window.hasOwnProperty('webkitAudioContext') && ^ ReferenceError: window is not defined
– CodeDude
Nov 11 at 15:23
I did add "var express = require('phaser');" to app.js. Now I get this error: C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesphasersrcpolyfillsAudioContextMonkeyPatch.js:60 if (window.hasOwnProperty('webkitAudioContext') && ^ ReferenceError: window is not defined
– CodeDude
Nov 11 at 15:23
nodejs does not provide DOM by default. You need to use something like jsdom to run your code against a specific DOM tree.
– lependu
Nov 11 at 15:29
nodejs does not provide DOM by default. You need to use something like jsdom to run your code against a specific DOM tree.
– lependu
Nov 11 at 15:29
How can i do this? I installed JSDOM and added 'const jsdom = require('jsdom') const { JSDOM } = jsdom;' in the test.js
– CodeDude
Nov 11 at 15:48
How can i do this? I installed JSDOM and added 'const jsdom = require('jsdom') const { JSDOM } = jsdom;' in the test.js
– CodeDude
Nov 11 at 15:48
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249950%2freferenceerror-phaser-is-not-defined-running-test-with-mocha%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You either need to compile your code with babel or use
require
instead of import.– lependu
Nov 11 at 15:11
I did add "var express = require('phaser');" to app.js. Now I get this error: C:UsersChrisDocumentsGitHubgamejam-challenge-nov18node_modulesphasersrcpolyfillsAudioContextMonkeyPatch.js:60 if (window.hasOwnProperty('webkitAudioContext') && ^ ReferenceError: window is not defined
– CodeDude
Nov 11 at 15:23
nodejs does not provide DOM by default. You need to use something like jsdom to run your code against a specific DOM tree.
– lependu
Nov 11 at 15:29
How can i do this? I installed JSDOM and added 'const jsdom = require('jsdom') const { JSDOM } = jsdom;' in the test.js
– CodeDude
Nov 11 at 15:48