Unit Test for Project
See original GitHub issueCore Library
MSAL.js v2 (@azure/msal-browser)
Core Library Version
2.19.1
Wrapper Library
MSAL Angular (@azure/msal-angular)
Wrapper Library Version
2.0.5
Description
I am trying to unit test using jest, but I am getting the below errors. How to resolve? Also, if I want to bypass MSALGuards for testing, how can you do this? A previous question links to a github that doesn’t exist anymore.
NullInjectorError: StaticInjectorError(DynamicTestModule)[MenuItemsComponent -> InjectionToken MSAL_GUARD_CONFIG]: StaticInjectorError(Platform: core)[MenuItemsComponent -> InjectionToken MSAL_GUARD_CONFIG]: NullInjectorError: No provider for InjectionToken MSAL_GUARD_CONFIG!
MSAL Configuration
No response
Relevant Code Snippets
import { TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';
import {CUSTOM_ELEMENTS_SCHEMA} from "@angular/core";
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [
AppComponent
]
}).compileComponents();
});
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
it(`should have as title 'ClientApp'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('ClientApp');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('.content span')?.textContent).toContain('ClientApp app is running!');
});
});
Identity Provider
Azure AD / MSA
Source
External (Customer)
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Create a unit test project - Visual Studio - Microsoft Learn
To create a unit test project · On the File menu, select New > Project, or press Ctrl+Shift+N. · On the Create a...
Read more >Unit Testing Tutorial – What is, Types & Test Example - Guru99
The purpose is to validate that each unit of the software code performs as expected. Unit Testing is done during the development (coding...
Read more >Unit Testing Tutorial: 6 Best Practices to Get Up To Speed
Read our unit testing tutorial to get up to speed. ... I'll right-click on the solution to add a project, and choose the...
Read more >7.4. Unit Testing - Applied Software Project Management [Book]
The main activity in unit testing is creating test cases that verify the software. A test case is a piece of code that...
Read more >A Basic Introduction To C# Unit Test For Beginners
In the software development process Unit Tests basically test individual parts ( also called as Unit ) of code (mostly methods) and make...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I want to add, I have an angular 12 project.
@gmiked This issue has been automatically marked as stale because it is marked as requiring author feedback but has not had any activity for 5 days. If your issue has been resolved please let us know by closing the issue. If your issue has not been resolved please leave a comment to keep this open. It will be closed automatically in 7 days if it remains stale.