Ember test failing on importing in config/environment - ember.js

When I run ember test on a project I am getting this error
Log: |
{ type: 'error',
text: 'Error: Could not find module `otherapp/config/environment` imported from `otherapp/tests/helpers/resolver` at http://localhost:7357/assets/vendor.js, line 173\n' }
...
not ok 2 PhantomJS 2.1 - Global error: Error: Assertion Failed: The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js". at http://localhost:7357/assets/vendor.js, line 15359
---
Log: |
{ type: 'error',
text: 'Error: Assertion Failed: The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js". at http://localhost:7357/assets/vendor.js, line 15359\n' }
...
I am not sure how to debug this, since this is happening in the test suite and there is no window to debug and placing debugger; doesn't help. Also this is someone else's project.
This is not a problem in the ember-cli or any packages as I created a new ember app and wrote some acceptance test without any such error. I am not sure how to trace or debug this error.

I had this issue and it was a strict mode bug. I was actually declaring a property on a controller with the same name twice.
you can debug phantomjs by mounting it onto a port and then browsing there.
put this in your testem.json
"phantomjs_debug_port": 9000
and then browse to localhost:9000 the second link with send you to the phantom dev tools!

Related

Error: ENOENT: no such file or directory, stat '/.VolumeIcon.icns'

Any idea why I would get this when trying to run component tests in Vue.js using Cypress? Is this a bug related to running on MacOS Catalina? (I ask because I think VolumeIcon.icns is a OS X thing??)
The following error was thrown by a plugin. We stopped running your tests because a plugin crashed. Please check your plugins file (/Users/MLaw/vue-app/tests/plugins/index.js)
Error: ENOENT: no such file or directory, stat '/.VolumeIcon.icns'
Error: The following error was thrown by a plugin. We stopped running your tests because a plugin crashed. Please check your plugins file (`/Users/MLaw/vue-app/tests/plugins/index.js`)
at Object.get (/Users/MLaw/Library/Caches/Cypress/5.6.0/Cypress.app/Contents/Resources/app/packages/server/lib/errors.js:968:15)
at EventEmitter.handleError (/Users/MLaw/Library/Caches/Cypress/5.6.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/index.js:159:20)
at EventEmitter.emit (events.js:310:20)
at ChildProcess.<anonymous> (/Users/MLaw/Library/Caches/Cypress/5.6.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:19:22)
at ChildProcess.emit (events.js:310:20)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:85:21)
My index.js looks like:
const preprocessor = require('#cypress/vue/dist/plugins/webpack');
module.exports = (on, config) => {
preprocessor(on, config);
// IMPORTANT return the config object
return config
};
sudo touch /.VolumeIcon.icns
I use M1 MacOS, it works for me.

can't import the test helper addon in ember-cli-mirage

Facing the same issue - https://github.com/miragejs/ember-cli-mirage/issues/1445
Uncaught Error: Could not find module project-name/tests/helpers/push-mirage-into-store imported from project-name/mirage/factories/addon
Initially got this error and tried #makepanic instructions
After that
Uncaught Error: Could not find module #ember/test-helpers imported from project-name/mirage/helpers/push-mirage-into-store
can you pls help here to resolve this.
I bet you are running into the error, which is described in this comment by makepanic in the GitHub issue you linked:
When running the app directly, the browser opens index.html which
isn't loading tests.js. This file contains everything related to
tests.
If you open tests/index.html, that will also load tests.js and add any
modules under tests/* to the loader registry.
This means without the tests file loaded, you can't import anything
from tests/*.
You are affected by that issue if you face it when running ember serve.
The comment also includes a possible solution:
With you moving the helpers to /mirage, they gets registered in both index.html and tests/index.html.
An alternative would be to disable mirage in all enrironments except for test. But that is only a feasible solution if you use mirage only for testing but not for development.

Can't run ember test

After many successful times running ember test and ember test -s, I can't run either of them on a specific project. The only thing I can think of that happened since it last ran successfully is that Terminal.app crashed while ember test -s was running.
Now when I run ember test -s on that project, I always get this error:
Global error: Error: Assertion Failed: The initializer 'container-debug-adapter' has
already been registered at http://localhost:7357/assets/vendor.js, line 38210
Global error: Error: Assertion Failed: The tests file was not loaded. Make sure your
tests index.html includes "assets/tests.js". at http://localhost:7357/assets/vendor.js, line 38210
Error: Assertion Failed: The initializer 'container-debug-adapter' has already been
registered at http://localhost:7357/assets/vendor.js, line 38210
Error: Assertion Failed: The tests file was not loaded. Make sure your tests
index.html includes "assets/tests.js". at http://localhost:7357/assets/vendor.js, line 38210
If I try running ember test -s on a different project, it works fine. So it seems to me that there must be something untracked by git that is sitting somewhere in the project folder that causes this problem.
Ember: 3.14.1
Ember CLI:
I solved the problem by deleting node_modules and package-lock.json and then running npm install.
I wish that I understood what could cause this and why reinstalling all of my dependencies would fix it.

Karma error - Unknown provider: $$asyncCallbackProvider

Trying to run my karma test through grunt but getting an error:
Error: [$injector:modulerr] Failed to instantiate module ngMock due to:
Error: [$injector:unpr] Unknown provider: $$asyncCallbackProvider
I removed 'ngAnimate' but does not resolve it. How can I run the grunt karma test without this error?
I had the same problem just now, and fixed it by making sure the version of my angular-mock dependancy was the same as that angular.
You can do this in your bower.json file (change "angular-mocks": "~1.3.0" to "angular-mocks": "^1.3.0" or a specific version).
While I have no doubt that 3sdmx's answer would work, I just ran an NPM update and that worked. Thought I should mention that so that people aren't maintaining their .json files so closely.
You should add all the angular dependencies that you used in your project to your karma.conf.js file.
It seems like you need to add ngMock to your karma file, like the example below :
files: [
'*/**/angula-ngMock.js'
],

How to unit test Dart in Phpstorm

I installed the dart plugin, set the SDK home path to the dart-sdk folder, configured the scope and checked the 'Dart SDK enabled' option in Phpstorm 6.0.3. Next, I created a dart file in a 'test' directory with the following code (obviously I added the dependency unittest in my pubspec.yaml and ran pub get):
library mytests;
import 'package:unittest/unittest.dart';
main(){
test('my test', (){
expect(1+1, equals(2));
});
}
When I run this unit test however (by right clicking inside the file and selecting 'Run Test: my test', an error is outputted in the unit testing window stating the following:
C:/dart/dart-sdk/bin/dart.exe --ignore-unrecognized-flags --package-root=C:/Users/myname/dart/pokerdart/test/packages/ C:\Users\myname\AppData\Local\Temp\jetbrains_unit_config.dart
Testing started at 18:55 ...
'file:///C:/Users/myname/AppData/Local/Temp/jetbrains_unit_config.dart': error: line 1 pos 1: unresolved implicit call to super constructor 'Configuration()'
import 'package:unittest/unittest.dart';
^
When I run the test using powershell it just works... Am I missing something/doing something wrong?
Any help is greatly appreciated!
WEB-9636 is fixed in version 7. Please try upgrading to PHPStorm 7.1.3. Or, even better, try PHPStorm 8 EAP (http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Early+Access+Program) - Dart support has been improved there