Karma test run throwing error on requirejs - requirejs

I have the below configuration in the karma config file.
frameworks: [
'jasmine',
'requirejs'
],
files: [
//App Bower components
{pattern: 'public/bower_components/**/*', included: false}
.....
// list of files / patterns to exclude
exclude: [
'public/bower_components/**/spec/**/*',
'public/bower_components/**/*spec*.js'
],
with this while running karma, i am getting the below error:
Running "karma:runner" (karma) task
WARN [watcher]: { [Error: EMFILE, readdir '/test-application/public/bower_components/requirejs/tests/commonjs/tests/modules/1.0/absolute/b.js']
errno: 20,
code: 'EMFILE',
path: '/test-application/public/bower_components/requirejs/tests/commonjs/tests/modules/1.0/absolute/b.js' }
Error: EMFILE, readdir '/test-application/public/bower_components/requirejs/tests/commonjs/tests/modules/1.0/absolute/b.js'
Fatal error: Cannot read property 'length' of undefined
I tried to add 'public/bower_components/requirejs/tests//*.js' & 'public/bower_components//tests/**/*.js' in the exclude section but i still get the same error.
Any idea on how to get this working.

The fix for the above seems to be not with karma but with the OSX. I had to do the below
ulimit -n 2560
in my bash_profile to get this to work.

Related

babel.config.js: Error while loading config - Cannot find module 'fibers'

This is driving me nuts.
IDE: Visual Studion 2019
Project: Created a new "Basic Vue.js project" - I chose the *.ts flavour
I validate the new site runs. It does.
Following the quick start on Vuetify : https://vuetifyjs.com/en/getting-started/quick-start/#bootstrapping-the-vuetify-object
After each step I validate the site will still compile and run.
I reach the section where we add new modules to our project. I run this line:
npm install sass sass-loader fibers deepmerge -D
And now the site will not run. When I debug I get this output:
------ Build started: Project: MCCC.Web, Configuration: Debug Any CPU ------
> mccc.web#0.1.0 build C:\Labs\MCCC\Web\MCCC-Web\MCCC.Web
> vue-cli-service build
- Building for production...
Starting type checking service...
Using 1 worker with 2048MB memory limit
ERROR Failed to compile with 1 errors5:04:50 PM
error in ./src/main.ts
Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 0)
C:\Labs\MCCC\Web\MCCC-Web\MCCC.Web\babel.config.js: Error while loading config - Cannot find module 'fibers'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (C:\Labs\MCCC\Web\MCCC-Web\MCCC.Web\babel.config.js:17:32)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
# multi ./src/main.ts
ERROR Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mccc.web#0.1.0 build: `vue-cli-service build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mccc.web#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Dwainwright.BC\AppData\Roaming\npm-cache\_logs\2020-04-26T21_04_50_521Z-debug.log
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VisualStudio\v16.0\Node.js Tools\Microsoft.NodejsToolsV2.targets(60,5): error MSB3073: The command "npm run build" exited with code 1.
Done building project "MCCC.Web.njsproj" -- FAILED.
Build FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The line that sticks out the most to me is:
C:\Labs\MCCC\Web\MCCC-Web\MCCC.Web\babel.config.js: Error while loading config - Cannot find module 'fibers'
fibres is references in the babel.config.json where I added the rules laid out in quick start:
module.exports = {
presets: [
'#vue/app',
'#babel/preset-env'
],
rules: [
{
test: /\.s(c|a)ss$/,
use: [
'vue-style-loader',
'css-loader',
{
loader: 'sass-loader',
// Requires sass-loader#^7.0.0
options: {
implementation: require('sass'),
fiber: require('fibers'),
indentedSyntax: true // optional
},
// Requires sass-loader#^8.0.0
options: {
implementation: require('sass'),
sassOptions: {
fiber: require('fibers'),
indentedSyntax: true // optional
},
},
},
],
},
]
};
Does anybody know how i can resolve this? Happy to share further info; not sure what else you may need.
Are you using the latest version of the docs? I followed the link you provided and the anchor #bootstrapping-the-vuetify-object doesn't appear to exist anymore. I was able to get a basic project up and running successfully following these steps:
vue create myapp: Selected "custom" and ticked all the boxes, for TypeScript, chose the default "class-style components"
verified that npm run serve worked
vue add vuetify: Selected "Configure", and these options:
Y (default)
y
y
Material Design Icons (default)
N (default)
Y (default)
English (default)
npm run serve would run, but I got warnings about type declaration for vuetify/lib. This answer led me to this FAQ item which made the warnings go away. (You have to add "vuetify" to the compilerOptions.types array in the root tsconfig.json for the project.)
FWIW, fibers does not appear to be included in the project at all anymore (searched for "fibers" in package-lock.json). My babel.config.js file looks like:
module.exports = {
presets: [
'#vue/cli-plugin-babel/preset'
]
}
And vue.config.js looks like:
module.exports = {
transpileDependencies: [
'vuetify'
]
}
Hope this helps!

Strange error trying to run ember tests on debian linux

All our tests pass on multiple macOS machines, and on semaphore-ci, but when we try to build and run tests on a new debian box, we get this error in loader.js:143
not ok 1320 Chrome 72.0 - TestLoader Failures: zipbooks/tests/unit/utils/request-log-test: could not be loaded
---
actual: >
null
stack: >
TypeError: Cannot read property 'exports' of undefined
at Module._reify (http://localhost:45371/assets/vendor.js:148:59)
at Module.reify (http://localhost:45371/assets/vendor.js:135:27)
at Module.exports (http://localhost:45371/assets/vendor.js:109:10)
at Module._reify (http://localhost:45371/assets/vendor.js:148:59)
at Module.reify (http://localhost:45371/assets/vendor.js:135:27)
at Module.exports (http://localhost:45371/assets/vendor.js:109:10)
at Module._reify (http://localhost:45371/assets/vendor.js:148:59)
at Module.reify (http://localhost:45371/assets/vendor.js:135:27)
at Module.exports (http://localhost:45371/assets/vendor.js:109:10)
at requireModule (http://localhost:45371/assets/vendor.js:32:18)
message: >
Died on test #1 at TestLoader.moduleLoadFailure (http://localhost:45371/assets/test-support.js:11150:24)
at TestLoader.<anonymous> (http://localhost:45371/assets/test-support.js:10463:16)
at TestLoader.require (http://localhost:45371/assets/test-support.js:10451:27)
at TestLoader.loadModules (http://localhost:45371/assets/test-support.js:10443:16)
at loadTests (http://localhost:45371/assets/test-support.js:11174:22)
at start (http://localhost:45371/assets/test-support.js:10857:33)
at Module.callback (http://localhost:45371/assets/tests.js:20710:25): Cannot read property 'exports' of undefined
Log: |
{ type: 'info',
text: '\'Unit assertion failed and test has been paused for inspection.\'\n' }
{ type: 'error',
text: '{ module: \'TestLoader Failures\',\n name: \'zipbooks/tests/unit/utils/request-log-test: could not be loaded\',\n result: false,\n message: \'Died on test #1 at TestLoader.moduleLoadFailure (http://localhost:45371/assets/test-support.js:11150:24)\\n at TestLoader.<anonymous> (http://localhost:45371/assets/test-support.js:10463:16)\\n at TestLoader.require (http://localhost:45371/assets/test-support.js:10451:27)\\n at TestLoader.loadModules (http://localhost:45371/assets/test-support.js:10443:16)\\n at loadTests (http://localhost:45371/assets/test-support.js:11174:22)\\n at start (http://localhost:45371/assets/test-support.js:10857:33)\\n at Module.callback (http://localhost:45371/assets/tests.js:20710:25): Cannot read property \\\'exports\\\' of undefined\',\n actual: null,\n testId: \'8629d10a\',\n negative: false,\n runtime: 1,\n todo: false,\n source: \'TypeError: Cannot read property \\\'exports\\\' of undefined\\n at Module._reify (http://localhost:45371/assets/vendor.js:148:59)\\n at Module.reify (http://localhost:45371/assets/vendor.js:135:27)\\n at Module.exports (http://localhost:45371/assets/vendor.js:109:10)\\n at Module._reify (http://localhost:45371/assets/vendor.js:148:59)\\n at Module.reify (http://localhost:45371/assets/vendor.js:135:27)\\n at Module.exports (http://localhost:45371/assets/vendor.js:109:10)\\n at Module._reify (http://localhost:45371/assets/vendor.js:148:59)\\n at Module.reify (http://localhost:45371/assets/vendor.js:135:27)\\n at Module.exports (http://localhost:45371/assets/vendor.js:109:10)\\n at requireModule (http://localhost:45371/assets/vendor.js:32:18)\' }\n' }
We cannot find any information or have any guesses what might be causing this error.
ember-cli: 3.1.4
node: 8.5.0
os: linux x64
The pattern I'm seeing is that any test that uses setupTest, setupApplicationTest or setupRenderingTest is failing. Regular qunit tests that dont have any setup hooks pass fine.
The problem was not installing the yarn dependencies in our in-repo addon 😑
The most likely cause is binary dependencies that are platform-specific. Have you tried running npm rebuild first? Certain dependencies (such as node-sass) use binaries that are platform-specific, and need to be rebuilt. If that's your issue, if you ever need to do this in an automated fashion, you'll want to limit the scope of the rebuild to only the necessary dependencies, e.g. npm rebuild some-package some-other-package rather than the all inclusive npm rebuild
Unfortunately, yarn has yet to implement the rebuild feature, so we've moved back to npm, for that and other reasons. -- link to issue in GitHub

Using Babel option blacklist to exclude es6.classes but getting Fatal error: Bundling failed. undefined during grunt build?

System.config({
defaultJSExtensions: true,
transpiler: "babel",
babelOptions: {
"optional": [
"runtime"
],
"blacklist": ['es6.classes'],
"nonStandard": false
},..................
Added blacklist option but not getting desired result for:
$ grunt build
getting:
Running "bundle" task
Building
Fatal error: Bundling failed. undefined
Is anyone have solution to this problem?

Trouble setting up karma-cordova (Linux)

First time doing anything on karma or linux so forgive me if I have made an obvious mistake.
Trying to run basic tests on karma-jasmine using cordova.
On karma start I get the following error logs:
30 10 2015 17:33:28.644:WARN [karma]: No captured browser, open http://localhost:9876/
30 10 2015 17:33:28.651:INFO [karma]: Karma v0.13.14 server started at http://localhost:9876/
using settings: { platforms: [ 'android', 'ios' ],
mode: 'emulate',
hostip: '10.0.2.2',
target: '0468de2a213eae29',
plugins: [ 'org.apache.cordova.console' ] }
30 10 2015 17:33:28.654:INFO [launcher]: Starting browser undefined on Cordova
30 10 2015 17:33:28.655:ERROR [launcher]: [TypeError: Object undefined on Cordova has no method 'on']
TypeError: Object undefined on Cordova has no method 'on'
at /home/phil/node_modules/karma/lib/launcher.js:94:17
at next (/home/phil/node_modules/karma/node_modules/batch/index.js:118:7)
at Batch.end (/home/phil/node_modules/karma/node_modules/batch/index.js:154:5)
at launch (/home/phil/node_modules/karma/lib/launcher.js:110:11)
at invoke (/home/phil/node_modules/karma/node_modules/di/lib/injector.js:75:15)
at Server.<anonymous> (/home/phil/node_modules/karma/lib/server.js:170:24)
at Server.g (events.js:180:16)
at Server.emit (events.js:92:17)
at net.js:1056:10
at process._tickCallback (node.js:448:13)
[spawn] stdout: Fetching plugin "org.apache.cordova.console" via npm
[spawn] stdout: WARNING: org.apache.cordova.console has been renamed to cordova-plugin-console. You may not be getting the latest version! We suggest youcordova plugin rm org.apache.cordova.consoleandcordova plugin add cordova-plugin-console.
Fetching plugin "org.apache.cordova.console" via cordova plugins registry
[spawn] stdout: Plugin "org.apache.cordova.console" already installed on android.
[spawn] stdout: Plugin "org.apache.cordova.console" already installed on ios.
[spawn] stderr: Platform android already added.
[spawn] stdout: WARNING: Applications for platform ios can not be built on this OS - linux.
[spawn] stderr: Platform ios already added.
Done adding platforms
[spawn] stdout: Running command: /tmp/cordova_test/platforms/android/cordova/build
[spawn] stderr: [Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]
[spawn] stdout: ERROR building one of the platforms: Error: /tmp/cordova_test/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
[spawn] stderr: Error: /tmp/cordova_test/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/root/.nvm/v0.10.40/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
30 10 2015 17:33:34.455:ERROR [launcher.cordova]: "cordova build" failed with code 1
Below is my karma.conf.js file:
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'*.js',
'test/test1/test1.js'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preproces sor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WAR N || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file chan ges
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launc her
browsers: ['Cordova'],
cordovaSettings: {
platforms:['android', 'ios'],
mode: 'emulate',
hostip: '10.0.2.2',
target :'0468de2a213eae29',
plugins: ['org.apache.cordova.console']
},
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
plugins: [
'karma-cordova-launcher',
'karma-jasmine',
'karma-cordova-launcher'
],
// Concurrency level
// how many browser should be started simultanous
concurrency: Infinity
})
}
Any advice appreciated, cheers!
Seems that the user running karma has not set the ANDROID_HOME environment variable.
Try opening the terminal and typing:
export ANDROID_HOME=/path/to/your/android/sdk
export PATH=$PATH:$ANDROID_HOME/bin
You can also add those lines to the user .bashrc to load them in each login.

Grunt process breaks at certain point generator-angular-fullstack

Can someone please help me explain what that does. The grunt process produces errors. I need to find out why. What does the "src" do?
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.client %>/assets/images',
src: '{,*/}*.{png,jpg,jpeg,gif}',
dest: '<%= yeoman.dist %>/public/assets/images'
}]
}
},
///// EDIT ///// Actual Output
Running "svgmin:dist" (svgmin) task
Total saved: 0 B
Done, without errors.
Execution Time (2014-07-12 09:39:26 UTC)
loading tasks 78ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 59%
svgmin:dist 54ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 41%
Total 132ms
Warning: Running "imagemin:dist" (imagemin) task
Warning: Command failed: Use --force to continue.
Aborted due to warnings.
Execution Time (2014-07-12 09:39:26 UTC)
loading tasks 188ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 62%
imagemin:dist 113ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 37%
Total 302ms Use --force to continue.
Aborted due to warnings.
///// EDIT 2 //////
With the command "grunt imagemin --verbose --force" I get the following error:
Files: client/assets/images/timeline/jd_small.png -> dist/public/assets/images/timeline/jd_small.png
Options: interlaced, optimizationLevel=3, progressive
Warning: Command failed: Used --force, continuing.
Fatal error: Cannot read property 'contents' of undefined
Not sure what that tells me though.
Ok it turned out that grunt throws an error if the image is corrupt. I opened it in Photoshop saved it and voila grunt worked.
Would be cool if grunt was able to output an error like that....

Resources