How to build Fabric.js for unit tests - javascript

When running the tests on master code npm test works fine,
but when I build Fabric locally (with node build.js modules=ALL)
the test breaks with error:
{ [Error: Cannot read property 'navigator' of undefined] message:
'Cannot read property \'navigator\' of undefined' }
Even without any changes to the codebase. I guess I'm missing some build flag.

Try this: node build.js modules=ALL exclude=gestures,cufon,json minifier=uglifyjs.

Related

Can get a prisma graphql to compile

When I run npm run dev I get this error and I have no idea what is causing it
I have installed all the packages and reinstalled them.
I have applied all of the migrations.
I have re-cloned the repo and done all the steps again and I cant seem to get past this error.
Error: Upload was already defined and imported as a type, check the docs for extending types
at extendError (C:\Users\coope\dev\paypixl\backend\node_modules\nexus\src\builder.ts:1743:10)
at SchemaBuilder.addType (C:\Users\coope\dev\paypixl\backend\node_modules\nexus\src\builder.ts:602:15)
at C:\Users\coope\dev\paypixl\backend\node_modules\nexus\src\builder.ts:1696:14
at C:\Users\coope\dev\paypixl\backend\node_modules\nexus\src\utils.ts:147:41
at Array.forEach (<anonymous>)
at eachObj (C:\Users\coope\dev\paypixl\backend\node_modules\nexus\src\utils.ts:147:20)
at SchemaBuilder.traverseArgs (C:\Users\coope\dev\paypixl\backend\node_modules\nexus\src\builder.ts:1693:12)
at SchemaBuilder.maybeTraverseOutputFieldType (C:\Users\coope\dev\paypixl\backend\node_modules\nexus\src\builder.ts:1688:12)
at Object.addField (C:\Users\coope\dev\paypixl\backend\node_modules\nexus\src\builder.ts:1640:29)
at ObjectDefinitionBlock.field (C:\Users\coope\dev\paypixl\backend\node_modules\nexus\src\definitions\definitionBlocks.ts:712:22)
[ERROR] 10:03:59 Error: Upload was already defined and imported as a type, check the docs for
extending types

Jest test fail: "Window is not defined"

In my React application I have configure Jest and Enzyme for snapshot testing.
One of my tests failed with an error:
ReferenceError {
message: 'window is not defined',
}
I'm using window (a global object) in a function and calling that function from a test file which contains a window object and that’s producing an error.
How can I resolve this? I tried
"globals":{
"window":true
}
in my package JSON file, but I am still having this issue.
My test script is also running jsdom.
It seems like JSDOM is not properly installed or somehow disabled. See if you can find something like this in your configuration:
"testEnvironment": "node"
https://jestjs.io/docs/en/configuration.html#testenvironment-string

mocha "describe" is not defined

I read all the related mocha "describe" is not defined posts but none of them seem to be suitable for my situation.
I use meteor and installed the "mocha": "^3.5.0" package by npm
I have created a /testfolder in my meteor root directory.
and a sample test mochatest.js
var assert = require("assert"); // node.js core module
describe('Array', function(){
describe('#indexOf()', function(){
it('should return -1 when the value is not present', function(){
assert.equal(-1, [1,2,3].indexOf(4)); // 4 is not present in this array so indexOf returns -1
})
})
});
When i run mocha the test passes.
But when i start my normal server i get: ReferenceError: describe is not defined
.meteor/packages/meteor-tool/.1.3.5_1.1wj76e8++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:280
throw(ex);
^
ReferenceError: describe is not defined
at meteorInstall.test.mochatest.js (test/mochatest.js:3:1)
at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1)
at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1)
at project-i18n.js:6:1
at .meteor/local/build/programs/server/boot.js:297:10
at Array.forEach (native)
at Function._.each._.forEach (.meteor/packages/meteor-tool/.1.3.5_1.1wj76e8++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
at .meteor/local/build/programs/server/boot.js:133:5
I have a feeling that meteor wants to run the test on startup but can't find mocha stuff.
So what to do?
You need to rename the /test folder to /tests.
From the official Meteor Testing Guide:
The Meteor build tool and the meteor test command ignore any files
located in any tests/ directory. This allows you to put tests in this
directory that you can run using a test runner outside of Meteor’s
built-in test tools and still not have those files loaded in your
application.
You could also consider renaming your test files with extensions like:
*.test[s].*, or *.spec[s].* -- So your file could be named mocha.test.js.
Such files are ignored by Meteor build tool as well.
Looks like the test file is somehow invoked when the server runs. It should not be included anywhere in the server code.
If you can't figure out what's happening, you can try to debug the server and put a breakpoint at the "describe" line - try to see how you got there.

Cannot read property 'engine' of undefined - Webpack React

I try to learn React.JS, by typing "webpack" command, i found this error :
Hash: 04008667f996e5267ae1 Version: webpack 1.14.0 Time: 580ms
+ 2 hidden modules
ERROR in ./public/assets/react-source/catalog-app.js Module build
failed: TypeError: Cannot read property 'engine' of undefined
at load (/var/www/html/web/node_modules/transform/index.js:33:18)
at Object.transform (/var/www/html/web/node_modules/transform/index.js:19:3)
ERROR in ./public/assets/react-source/catalog-custom-item-app.js
Module build failed: TypeError: Cannot read property 'engine' of
undefined
at load (/var/www/html/web/node_modules/transform/index.js:33:18)
at Object.transform (/var/www/html/web/node_modules/transform/index.js:19:3)
Anyone can help pls ?
Already installed react-engine. My react app running well before.
Problem solved by typing this command :
npm install transform
then
npm install

Error with "cake build:browser" and Uglify.js -- Cannot read property 'Array' of undefined

I just installed Uglify.js and tried to use it to rebuild CoffeeScript, but keep getting this error. This happens when I type "cake build:browser" in the CoffeeScript directory. (I want to try my hand at modifying the CoffeeScript language.)
My Uglify.js was cloned from GitHub and the symbolic link was created in .node_libraries. Uglify is installed correctly, confirmed since it runs properly in Node and through the command line. So maybe this is a CoffeeScript problem.
Help?
/Users/myuser/projects/UglifyJS/lib/process.js:475
return options.defines[name];
^
TypeError: Cannot read property 'Array' of undefined
at get_define (/Users/myuser/projects/UglifyJS/lib/process.js:475:47)
at Array.<anonymous> (/Users/myuser/projects/UglifyJS/lib/process.js:527:32)
at walk (/Users/myuser/projects/UglifyJS/lib/process.js:215:47)
at Array.<anonymous> (/Users/myuser/projects/UglifyJS/lib/process.js:164:59)
at walk (/Users/myuser/projects/UglifyJS/lib/process.js:220:36)
at Array.<anonymous> (/Users/myuser/projects/UglifyJS/lib/process.js:146:43)
at walk (/Users/myuser/projects/UglifyJS/lib/process.js:220:36)
at /Users/myuser/projects/UglifyJS/lib/process.js:1643:37
at Array._block (/Users/myuser/projects/UglifyJS/lib/process.js:81:34)
at walk (/Users/myuser/projects/UglifyJS/lib/process.js:220:36)
OK, I was able to replicate this. But why are you cloning the UglifyJS repo? If you just do npm install uglify-js to install to the local node-modules directory (with npm 1.x), everything runs fine.
Similar issue: https://github.com/mishoo/UglifyJS/issues/140

Categories

Resources