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.

Add Unit Tests to core APIs

See original GitHub issue

We have has some regressions slip through using snapshot testing.

We need to have some proper unit testing on the core APIs to ensure regressions don’t slip through accidentally with a ava --update-snapshots command that shouldn’t have happened.

Here is a quick example for the git utility

const test = require('ava')
const gitUtils = require('@netlify/git-utils')

test('Verify git utils API methods exist', async (t) => {
  t.is(typeof gitUtils, 'object')
  t.is(typeof gitUtils.fileMatch, 'function')
  t.is(typeof gitUtils.linesOfCode, 'function')
  t.is(Array.isArray(gitUtils.modifiedFiles), true)
  t.is(Array.isArray(gitUtils.deletedFiles), true)
  t.is(Array.isArray(gitUtils.createdFiles), true)
  t.is(Array.isArray(gitUtils.commits), true)
})

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ehmickycommented, Mar 25, 2020

I actually added module testing for each utils and for @netlify/config, on top of existing integration tests. So now, each package in the monorepo has its own sets of module tests, but all of the packages together as a whole are also covered with integration tests.

0reactions
erquhartcommented, Mar 25, 2020

We’ll revisit testing as needed moving forward, integration tests are sufficient right now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unit Testing in ASP.NET Core Web API - Code Maze Blog
Find out what Unit testing is and how to write unit tests in ASP.NET Core Web API Project to test Controllers and Repo...
Read more >
Unit Testing ASP.NET Web API 2 - Microsoft Learn
This guidance and application demonstrate how to create simple unit tests for your Web API 2 application. This tutorial shows how to include ......
Read more >
Unit Testing In ASP.NET Core Web API - Medium
Step by step implementation of ASP.NET Core web API Unit testing using xUnit. ... A unit test is a code you can write...
Read more >
Part 2 - Unit Tests - Creating Web API in ASP.NET Core 2.0
NET Core 2.0. Part 2 - Unit Tests. Step 07 - Add Unit Tests. In order to add unit tests for API project,...
Read more >
Unit Testing Asp.NetCore Web API Using xUnit ... - Tech Seeker
The xUnit for .Net is a free, open-source, community-focused unit testing tool for .NET applications. By default .Net also provides a xUnit ...
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