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;

}









share|improve this question






















  • 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















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;

}









share|improve this question






















  • 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













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;

}









share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 14:57









CodeDude

11




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












  • 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










  • 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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues