Ember CLI: Attempting to register an unknown factory: `controller:object` - ember.js

My ember-cli version is 0.2.3. I am getting the following error when I try to run tests.
TypeError: Attempting to register an unknown factory: `controller:object`
at Object.Registry.register (http://localhost:7357/assets/vendor.js:12208:15)
at Object.container.(anonymous function) [as register] (http://localhost:7357/assets/test-support.js:1905:44)
at Object.isolatedContainer [as default] (http://localhost:7357/assets/test-support.js:1946:15)
at exports.default.klassy.Klass.extend._setupIsolatedContainer (http://localhost:7357/assets/test-support.js:2406:52)
at exports.default.klassy.Klass.extend.setupContainer (http://localhost:7357/assets/test-support.js:2312:14)
at nextStep (http://localhost:7357/assets/test-support.js:2300:53)
at exports.default.klassy.Klass.extend.invokeSteps (http://localhost:7357/assets/test-support.js:2305:14)
at exports.default.klassy.Klass.extend.setup (http://localhost:7357/assets/test-support.js:2275:19)
at Object.qunit.module.setup (http://localhost:7357/assets/test-support.js:1814:16)
at runHook (http://localhost:7357/assets/test-support.js:3534:20)
Any idea on what might be causing this? Looking like a ember-cli internal issue.
I am actually using v2.3.0-beta.2 of Ember CLI. When you fire it up, it displays v0.2.3 on terminal for some reason.
Ember version is 2.0.
I have a unit test for a model that triggers this. The test is using moduleFor rather than moduleForModel as my app doesn't use Ember Data.

I am actually using v2.3.0-beta.2 of Ember CLI. When you fire it up, it displays v0.2.3 on terminal for some reason.
This happens because your globally installed Ember CLI is different from the version specified in the project's package.json.
What Ember CLI does when you run a command if check if it's inside an Ember project. It does this by checking for a package.json file in the current, or parent, directory. If it finds it, it will then delegate the command to the Ember CLI that your project depends on.
This is done to make sure that the commands (generate, build, etc) called are the right version and won't break your application.

Related

Jest Test Suite Failed after adding the firebase-admin

I added a firebase-admin in the NestJS Project, the unit test pass in the local code but fails in the CI/CD Pipeline.
Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
/opt/atlassian/pipelines/agent/build/node_modules/firebase-admin/lib/app/firebase-namespace.js:84
this.INTERNAL = new FirebaseNamespaceInternals(appStore ?? new lifecycle_1.AppStore());
^
SyntaxError: Unexpected token '?'
at compileFunction (<anonymous>)
at Runtime._execModule (../node_modules/jest-runtime/build/index.js:1157:58)
at Object.<anonymous> (../node_modules/firebase-admin/lib/default-namespace.js:19:30)
at Object.<anonymous> (../node_modules/firebase-admin/lib/index.js:19:18)
All the tests passed locally from VS Code
I tried adding the testPathIgnorePatterns and other settings provided on the web. Didn't work.
The Nullish Coalescing Operator (??) was introduced to Node in version 14. Update your CI/CD pipeline to be a newer version of Node. The current version is 18 and I believe 12 is no longer LTS so upgrading is definitely something to look into.

New Ember project: The "data" argument must be of type string or an instance

I used the cli to create a new Ember project (v2.18). I'm getting the following error when I try to build/serve the project. This is with 100% clean project, no edits yet. Also fwiw, am using node v14.19.3, npm v6.14.17.
- stack: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
at Object.writeFileSync (fs.js:1522:5)
at module.exports (/Users/nikoleizinsli/IdeaProjects/custom-fields-admin/node_modules/ember-cli/lib/utilities/attempt-never-index.js:26:6)
at Builder.build (/Users/nikoleizinsli/IdeaProjects/custom-fields-admin/node_modules/ember-cli/lib/models/builder.js:156:5)
at BuildTask.run (/Users/nikoleizinsli/IdeaProjects/custom-fields-admin/node_modules/ember-cli/lib/tasks/build.js:29:20)
at /Users/nikoleizinsli/IdeaProjects/custom-fields-admin/node_modules/ember-cli/lib/models/command.js:243:46
at tryCatcher (/Users/nikoleizinsli/IdeaProjects/custom-fields-admin/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:326:21)
at invokeCallback (/Users/nikoleizinsli/IdeaProjects/custom-fields-admin/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:498:33)
at /Users/nikoleizinsli/IdeaProjects/custom-fields-admin/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:562:16
at flush (/Users/nikoleizinsli/IdeaProjects/custom-fields-admin/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:2441:7)
at processTicksAndRejections (internal/process/task_queues.js:77:11)
UPDATE: I was able to get it to build by using Node v13. We have another Ember 2.18 project that compiles fine on Node v14...so not sure what is causing this.
Any reason you're using that version of Ember? It stopped getting updates in 2018. I'd guess this is an issue with Node 14, you may need to go back to Node 10 to get support for ember-cli 2.18. Or, even better, run npm install -g ember-cli to get the 4.4 version which supports Node 14+.

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.

Unit testing Quartz plugin for Grails

I have some trouble writing the most basic unit test for a job. My problem can be recreated by creating a new job by running grails create-job my in the console.
This will create two files
MyJob.goovy (under the default package myApp - resides in test\unit\myApp)
MyJobSpec.groovy (under the default package myApp - resides in grails-app\jobs\myApp)
Now if i try to use the job MyJob in the test, as example
import myApp.MyJob //This is not resolved
#TestMixin(GrailsUnitTestMixin)
class MyJobSpec extends Specification {
def myJob
I get the compiler error Groovy:unable to resolve class MyJob. Everything so far was automatically created by the plugin. What is going on here? Is there something i did wrong / how do i get this to work?
Using grails 2.3.11.
I don't know which IDE are you using or if you are running everything on a terminal, but I had similar problems with Eclipse and what you need to do is to add grails-app/jobs to the classpath as a source folder.

Running unit tests in Pydev

I am trying to run unit tests in Pydev using IronPython.
When I try to run a test with Ctrl+F9 the following error message shows up in the Eclipse console window:
AttributeError: 'module' object has no attribute '_getframe'
I figured out that I have to invoke the IronPython interpreter with the '-X:Frames' argument.
Setting up the arguments in the 'Arguments' tab under 'Run->Run Configurations...' doesn't work. They seem to disappear everytime I run (Ctrl+F9) and choose another test.
Clicking 'Run->Run As->Iron Python unit-test' shows up more and more options to choose from.
Is Eclipse/Pydev creating new run configurations everytime I run a different set of tests? How can I permanently pass the '-X:Frames' argument, so my tests will run under IronPython?
(In Python the tests run without any problem.)
This shouldn't really be needed... I've just fixed the PyDev unittest runner so that it works properly (just pushed a new nightly build with that fix included -- if you're in Aptana Studio 3, a nightly is still not available, but you can patch your own version by applying the changes from the commit locally, as they're all changes in Python code: https://github.com/aptana/Pydev/commit/d5d262dbcd0c126ec0ec37e116ff79575c5dd6d8)