Ember.js测试报错:Assertion Failed: fullName必须是合法全名的含义解析
Hey there! Let me break down this Ember.js test error you're hitting—it's actually pretty straightforward once you know what Ember expects.
This error is Ember's way of flagging that somewhere in your test code (or the application code your test is running), you've passed an invalid fullName value when Ember requires a properly formatted one.
Ember relies on these structured fullNames to identify all its core objects—services, components, routes, templates, models, and more. A valid fullName always follows the pattern: type:name, where:
- The
typeis a recognized Ember object type (likeservice,component,route,model,template, etc.) - The
nameis the standard kebab-case or camelCase name of your specific object (kebab-case is the usual convention for components and templates)
Common Causes of This Error
- Missing or wrong type prefix: For example, trying to look up an auth service with just
authinstead of the requiredservice:authwill trigger this failure. - Typos in the type or name: A silly typo like
servce:auth(missing an 'i') orcomponent:user-profle(typo in the component name) breaks the valid format. - Passing empty/undefined values: If your code accidentally passes
null,undefined, or an empty string where a fullName is required, Ember's assertion will fail. - Invalid formatting: Using spaces, weird special characters, or uppercase letters in the type prefix (like
Service:auth) also counts as an invalid fullName.
Quick Fix Example
If your test has code like this (invalid lookup):
this.lookup('auth'); // ❌ No type prefix = invalid fullName
Update it to the correct formatted fullName:
this.lookup('service:auth'); // ✅ Properly formatted service reference
Or if you're rendering a component in a test and hitting this error:
// ❌ If you're using raw strings without the right component reference this.render('<user-profile />'); // ✅ Use the hbs template helper for proper component resolution this.render(hbs`<user-profile />`);
At the end of the day, this is just Ember's guardrail making sure you're referencing its objects exactly the way it needs to find them—so double-check any place you're looking up, registering, or referencing Ember objects in your tests!
内容的提问来源于stack exchange,提问作者Ahmet Emre Kilinc

