Navan Tech Blog
How We Turbocharged Our Unit Tests and Reclaimed Developer Velocity

How We Turbocharged Our Unit Tests and Reclaimed Developer Velocity

Harshal Carpenter

February 27, 2026
4 minute read

Our front-end engineering team at Navan Expense was battling a silent, insidious problem: slow, flaky unit tests. This was no small issue. It had created a bottleneck that was grinding our development and release pipelines to a crawl. At Navan, we constantly push ourselves to increase velocity, and this was costing us valuable time and resources.

Here’s the story of how a focused and talented team, armed with data, collaboratively transformed a major pain point into a triumph of efficiency.

The Problem: When Unit Tests Become the Bottleneck

Imagine a development process where pull requests time out, automated builds frequently fail, and every code change feels like navigating a minefield. This was our reality. Our unit tests had become a source of immense friction, leading to:

  • Blocked pipelines: Long-running tests caused timeouts and process terminations, blocking our release and development pipelines multiple times a day.
  • Frequent failures: Our release workflows were constantly impacted by an average failure rate of ~30% (some days up to 100%), delaying critical updates.
  • Slow feedback: Individual unit tests for our user-facing apps took an agonizingly long time to run (40 minutes for the user app; 36 minutes for the admin app), stifling agility.

Technical Deep Dive: Unmasking the Culprits

Our investigation into sluggish test times led us directly to two primary root causes: barrel files and circular dependencies. While seemingly innocuous, these structures were causing our testing framework (Jest) to pull in vast, unnecessary amounts of code during every test run.

Barrel files run amok

A barrel file is a single file (generally named “index.ts”) that re-exports multiple modules, components, or utilities from a directory. It simplifies imports by allowing everything to be imported from one central file instead of importing each file individually.

turbocharge 1

Above: Barrel file example

Even when running a single test file, Jest was importing a huge web of unrelated code through aggregated “index.ts” files, creating a sprawling, inefficient dependency graph.

Starting with the above example, let’s say your file used the button component; it would still import back-button, form-modules, and company-modules with it:

turbocharge 2

Importing directly would load only button:

Turbocharge 3

Circular dependencies:

These dependencies created intricate, self-referential loops within our code base. This entanglement further bloated the test environment and made it extremely difficult for Jest to isolate components effectively.

Legacy modules

Shared Angular modules in older parts of our application systems also contributed by forcing the full import of large modules for single-component tests.

Confirming Our Hypothesis: Insights from Targeted Testing

Before committing to a large-scale refactor, we rigorously tested our assumptions on a small test file within our library — a piece of code designed to be quick to run.

  • The baseline: Running this single test initially took a staggering 105 seconds locally.
  • Barrel file impact isolated: Incrementally removing unnecessary imports from barrel files for this test reduced the run time to just 10 seconds. This dramatic reduction provided irrefutable evidence of the severe performance impact of barrel files.
  • Circular dependency’s role: Even after cleaning up barrel files, test times remained high if circular dependencies persisted. Resolving a specific circular dependency reduced unit test time from ~13 minutes to ~4 minutes.

Teamwork in Action: Our Incremental Path to Victory

Tackling a problem of this magnitude required a strategic, collaborative approach. Recognizing the risks of a “big bang” refactor, we opted for an incremental, team-driven barrel file and circular dependency removal strategy that included:

  • Distributed ownership: The team collectively assigned specific barrel files or sections, distributing the workload and fostering shared responsibility.
  • Dedicated reviewers: A core group of experienced developers ensured consistency and quality.
  • Iterative perfection: This process was repeated until each barrel file was empty and could be safely deleted, prioritizing the largest offenders.
  • Leveraging AI for efficiency: We used AI to generate a script using ts-morph to automate a significant portion of the import removal process. This allowed us to efficiently update corresponding imports across the repository to point directly to the new, non-barrel file URLs as exports were removed.

The Impact: Faster Cycles, Greater Stability, Real Savings

The results of this concerted effort have been transformative:

Overall unit test time reduced by 50%

Developers now get feedback much faster, allowing them to iterate and merge code at an unprecedented pace.

turbocharge 4 - updated
turbocharge 5

Enhanced stability and reliability

We’ve seen a dramatic decrease in pipeline blocking and failures. Many test types now experience periods of 0% failure rates, eliminating false positives and allowing us to take targeted action when failures do occur.

Significant cost savings:

The average cost per unit test job has decreased by 44%, from a peak of $0.051 to $0.022, leading to substantial savings within our testing infrastructure.

turbocharge 6

Building for the Future: Preventing Regressions

To safeguard these gains, we’ve implemented proactive measures:

  • PR checks: Automated checks now prevent imports from reintroducing large barrel files.
  • ESLint rules: New ESLint rules restrict the creation of new barrel files.
  • ESLint rule and PR checks for circular dependencies: We are also working on an ESLint rule to ban circular dependencies between projects.

This journey wasn’t just about code; it was about smart problem-solving, meticulous execution, and the power of a dedicated team, augmented by innovative tools like AI-generated scripts. Thanks to the dedicated efforts of the Navan Expense front-end engineering team, our development workflow is now faster, more stable, and significantly more cost-effective.



This content is for informational purposes only. It doesn't necessarily reflect the views of Navan and should not be construed as legal, tax, benefits, financial, accounting, or other advice. If you need specific advice for your business, please consult with an expert, as rules and regulations change regularly.

More content you might like

4.7out of5|8.5K+ reviews

Take Travel and Expense Further with Navan

Move faster, stay compliant, and save smarter.