Skip to content

test(angular): Increase Angular SDK test coverage. #5790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 5, 2022
Merged

Conversation

onurtemizkan
Copy link
Collaborator

@onurtemizkan onurtemizkan commented Sep 21, 2022

Resolves: #4143

This PR increases unit test coverage of Angular SDK by integrating TestBed.

The main work here is done on tracing.ts which had low test coverage, and the previous tests were faking the angular router.

I attempted to use @testing-library/angular to be consistent with other SDK tests like @sentry/react and @sentry/svelte, but it was not possible as it doesn't support renders without compiled components which we need while testing TraceService.

Coverage before:

-----------------|---------|----------|---------|---------|-----------------------------------------
File             | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                       
-----------------|---------|----------|---------|---------|-----------------------------------------
All files        |    76.5 |    68.57 |   52.27 |   75.43 |                                         
 constants.ts    |     100 |      100 |     100 |     100 |                                         
 errorhandler.ts |   90.24 |    88.23 |     100 |   89.74 | 68,78-79,120                            
 flags.ts        |     100 |       50 |     100 |     100 | 13                                      
 index.ts        |     100 |      100 |   18.18 |     100 |                                         
 sdk.ts          |   93.33 |       60 |     100 |   93.33 | 33                                      
 tracing.ts      |   63.46 |    64.86 |   45.45 |   61.85 | ...1,87,128-133,173-188,210-233,245-264 
 zone.ts         |     100 |       50 |     100 |     100 | 12-27                                   
-----------------|---------|----------|---------|---------|-----------------------------------------

Coverage after:

------------------|---------|----------|---------|---------|-------------------
File              | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
------------------|---------|----------|---------|---------|-------------------
All files         |   97.22 |    86.02 |   88.23 |      97 |                   
 src              |   96.72 |    85.71 |   86.36 |   96.49 |                   
  constants.ts    |     100 |      100 |     100 |     100 |                   
  errorhandler.ts |   97.56 |      100 |     100 |   97.43 | 120               
  flags.ts        |     100 |       50 |     100 |     100 | 13                
  index.ts        |     100 |      100 |   45.45 |     100 |                   
  sdk.ts          |   93.33 |       60 |     100 |   93.33 | 33                
  tracing.ts      |   96.15 |    89.18 |     100 |   95.87 | 56,69-71,87       
  zone.ts         |     100 |       75 |     100 |     100 | 27                
 test/utils       |     100 |    86.95 |     100 |     100 |                   
  index.ts        |     100 |    86.95 |     100 |     100 | 50,52,80          
------------------|---------|----------|---------|---------|-------------------

@onurtemizkan onurtemizkan self-assigned this Sep 21, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 22, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.49 KB (+0.02% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 60.29 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.11 KB (-0.01% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 53.22 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 19.83 KB (0%)
@sentry/browser - Webpack (minified) 64.56 KB (0%)
@sentry/react - Webpack (gzipped + minified) 19.85 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 44.75 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.94 KB (0%)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.38 KB (+0.01% 🔺)

@onurtemizkan onurtemizkan marked this pull request as ready for review September 27, 2022 12:54
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks @onurtemizkan for adding Angular tests! This has been on my Angular SDK ToDo list for quite a while. Also, great that you figured out a way to get TestBed working. I tried a bunch of stuff when I was adding the router parameterization tests but didn't get it working and tabled it for "later".

I still had some questions and suggestions but overall I think we can merge this soon.

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing my feedback! 🚀

@Lms24 Lms24 merged commit fcde2a8 into master Oct 5, 2022
@Lms24 Lms24 deleted the onur/angular-tests branch October 5, 2022 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tests for @sentry/angular
2 participants