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.

Unit Test for Project

See original GitHub issue

Core 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:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gmikedcommented, Feb 9, 2022

I want to add, I have an angular 12 project.

0reactions
msftbot[bot]commented, Feb 17, 2022

@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.

Read more comments on GitHub >

github_iconTop 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 >

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