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.

Support for unit testing frameworks on pages with <swal /> components

See original GitHub issue

When testing pages using Jest or Jasmine with <swal> components or partials, importing the module or component at the top of the page leads to the following error.

                                                                                                        ```                                                                                                                
StaticInjectorError[InjectionToken SwalDefaults]:                                                                                                                                                                           
  StaticInjectorError[InjectionToken SwalDefaults]:                                                                                                                                                                         
    NullInjectorError: No provider for InjectionToken SwalDefaults! 

The alerts are working all over the app, and regular Swal() in the code work fine, even in tests.

Any help is appreciated! 

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
prmkishorcommented, Apr 6, 2020

Unit testing with sweetAlert is very easy and handy. Please folor this link https://github.com/prmkishor/sweetAletUnitTesting/wiki/sweetAlert2-Angular-Unit-Testing

2reactions
toveruxcommented, Aug 31, 2019

No provider for InjectionToken SwalDefaults means that you (probably?) didn’t use forRoot and therefore, you haven’t provided that token to the library, which needs it. If you need more help please open a new issue, showing how you declared your tests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Write Tests for Your Lightning Components Unit - Trailhead
Explain the role of the Lightning Test Service, its helpers, and execution methods. ... This is a modern framework for building single-page applications ......
Read more >
JavaScript unit testing frameworks in 2022: A comparison
We examined 11 of the most popular JavaScript unit testing frameworks according to stateofjs.com, to help you decide which is best for you....
Read more >
Testing - Lit.dev
Lit is a standard modern Javascript library, and you can use virtually any Javascript testing framework to test your Lit code.
Read more >
20 Most Popular Unit Testing Tools in 2022
Here is the list of top Unit Testing Frameworks used by developers ... unit test; It supports data-driven testing using a group of...
Read more >
swal popup
Swal PopupYou can add the custom animation using the Animate CSS, ... only to those alerts you want to be wide: swal (...
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