

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

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:

Importing directly would load only button:

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.
Shared Angular modules in older parts of our application systems also contributed by forcing the full import of large modules for single-component tests.
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.
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:
The results of this concerted effort have been transformative:
Developers now get feedback much faster, allowing them to iterate and merge code at an unprecedented pace.


We’ve seen a dramatic decrease in pipeline blocking and failures. Many test types now experience periods of
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.


To safeguard these gains, we’ve implemented proactive measures:
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.
Take Travel and Expense Further with Navan
Move faster, stay compliant, and save smarter.