question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FontAwesome: Could not find icon with iconName=plus and prefix=fas. This warning will become a hard error in 0.6.0.

See original GitHub issue

I use FontAwesome into my application, that in constructor import a library:

export class CoreModule {
    constructor(library: FaIconLibrary) {
        library.addIconPacks(fas);
    }
}

when i do test with angular testing library

import {render} from '@testing-library/angular';
import {screen} from '@testing-library/dom';
import {DialogWrapperComponent} from './dialog-wrapper.component';
import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
import {FaIconLibrary, FontAwesomeModule} from '@fortawesome/angular-fontawesome';
import {fas} from '@fortawesome/free-solid-svg-icons';
import {SharedModule} from '../shared.module';
import {CoreModule} from '../../core/core.module';
import {NO_ERRORS_SCHEMA} from '@angular/core';
import {TestBed} from '@angular/core/testing';

describe('first test', () => {

    test('first input test', async () => {
        TestBed.configureTestingModule({
            schemas: [NO_ERRORS_SCHEMA],
            imports: [FontAwesomeModule],
        }).compileComponents();

        const close = jest.fn();
        const {click} = await render(DialogWrapperComponent, {
            declarations: [],
            imports: [
                FontAwesomeModule,
            ],
            providers: [
                NgbModal,
            ],
            componentProperties: {
                title: 'hello',
               --> iconColorPair: {icon: 'plus', color: 'black'},
                modalClose: {
                    emit: close,
                } as any
            },
        });
        const title = screen.getByText('hello');
        const iconClose = screen.getByTestId('btn-close');
        --> const icon = screen.getByText('fas, file');
        click(iconClose);
        expect(close).toHaveBeenCalledTimes(1);
    });
});

the test write this message FontAwesome: Could not find icon with iconName=plus and prefix=fas. This warning will become a hard error in 0.6.0.

Someone can help me? please

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
georgy-alarconcommented, Mar 31, 2020

ok i resolve!! i create a new module only for the icon a then import this into my render method

import { NgModule } from '@angular/core';
import { FontAwesomeModule, FaIconLibrary } from '@fortawesome/angular-fontawesome';
import {fas} from '@fortawesome/free-solid-svg-icons';

@NgModule({
    imports: [ FontAwesomeModule ],
    exports: [ FontAwesomeModule ],
    bootstrap: [],
})
export class IconsModule {
    constructor(library: FaIconLibrary) {
        library.addIconPacks(fas);
    }
}
const {click} = await render(DialogWrapperComponent, {
            declarations: [
            ],
            imports: [
                FontAwesomeModule,
                --> IconsModule
            ],
            providers: [
                NgbModal,
            ],
            componentProperties: {
                title: 'hello',
                iconColorPair: {icon: 'plus', color: 'black'},
                modalClose: {
                    emit: close,
                } as any
            },
        });
0reactions
sanchitoscommented, Oct 15, 2021

@georgy-alarcon Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Font Awesome 5: Could not find icon money-check
Look at the icon's page: it was added in 5.0.13 - and you seem to be using 5.1.0-8. user-check is from 5.1.0.11.
Read more >
Help and Troubleshooting | Font Awesome Docs
You can find tips and support for desktop issues in Troubleshooting on the Desktop. The icon I want to use is missing or...
Read more >
@fortawesome/angular-fontawesome - npm
Start using @fortawesome/angular-fontawesome in your project by running ... TypeScript icon, indicating that this package has built-in type ...
Read more >
How To Use Font Awesome icons in Angular Applications
If you get the above error that means you are using older version of angular fontawesome icons. Then use the legacy icon library...
Read more >
Font Awesome icons in Vue.js apps: A complete guide
In this tutorial, learn to add those icons to your Vue.js app. ... wish to try the online demo, see below, but be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found