Services
About
Portfolio
Careers
Blog
Get in touch
Loading articles

Apptension site footer

Taking new projects

Have a product to build, fix or scale?

Apptension is a senior-only software development company headquartered in Poznań, Poland. Since 2012 our engineers have shipped 360+ AI and SaaS products for startups, scale-ups and enterprises across the US, UK and EU: agentic MVPs, RAG and voice AI systems, multi-tenant SaaS and legacy modernization.

Projects shipped
360+
Founded
2012
Senior engineers
30+
Client CSAT
100%

Send a few lines about your product. A person from our team replies within one business day.

Start a projectScope it in Scope Studio
  • Emailcontact@apptension.com
  • Phone+48 533 352 052Poznań, Poland

  • Agentic MVP developmentNew
  • Agentic SDLC implementation
  • Product & SaaS development
  • Legacy modernization
  • Generative AI development
  • SaaS development company
  • Vibe-coded prototype to production
  • End-to-end software development
  • Senior engineering team extension
  • Product consulting & discovery
  • Tech due diligence for investors
  • All services

  • LLM application engineering
  • RAG & retrieval engineering
  • Voice AI agent development
  • MCP server development
  • LangGraph & LangChain agents
  • AI agent evaluation & observability
  • Node.js development company
  • Python & Django development
  • React & Next.js development
  • React Native app development
  • All expertise

  • Open-source SaaS Boilerplate
  • SaaS P&L model template
  • Walkthrough Studio
  • Agentic SDLC playbook
  • AI SDLC maturity assessment
  • Agentic SDLC ROI calculator
  • Founder resources
  • Events & exec dinners
  • Open source
  • Builder's Toolkit

  • Boutique vs large software house
  • Build vs buy vs partner
  • How to choose an AI & RAG partner
  • Team augmentation without chaos
  • Django vs Node.js for SaaS
  • React Native vs Flutter
  • AI in regulated industries
  • All guides

  • About Apptension
  • Case studies
  • Careers
  • Blog
  • Tech Radar
  • Agentic SDLC hub
  • Contact

Senior AI engineers shipping enterprise-grade AI and SaaS with startup speed.

Headquarters

Apptension sp. z o.o.23 Lutego 26
61-743 Poznań, Poland (opens Google Maps)

VAT-ID PL7831720203 · REGON 360404804
KRS 0000534235

Follow Apptension

Client reviews on Clutch

© 2012–2026 Apptension sp. z o.o. All rights reserved.

Privacy policySitemapllms.txt
  • 01Services
  • 02Portfolio
  • 03About
  • 04Careers
  • 05Blog

Services

All services

New · AI-native delivery

Senior engineers with AI coding agents

Ship a production MVP in weeks, or install agents into the team you already have.

Agentic MVPNewA production MVP your customers can rely on. Validate in 1–2 weeks, launch in 4–8, own all of it.Explore
  • Agentic SDLCAI coding agents installed into your delivery process in two weeks, with guardrails and metrics.
Agentic SDLC hub
>_ProductScope StudioFrom an idea to a shareable PRD_> Open_> Open
Emailcontact@apptension.comCall+48 533 352 052

HQ in Poznań, Poland

Start a project
Services
About
Portfolio
Careers
Blog
Get in touch
Loading article

Apptension site footer

Taking new projects

Have a product to build, fix or scale?

Apptension is a senior-only software development company headquartered in Poznań, Poland. Since 2012 our engineers have shipped 360+ AI and SaaS products for startups, scale-ups and enterprises across the US, UK and EU: agentic MVPs, RAG and voice AI systems, multi-tenant SaaS and legacy modernization.

Projects shipped
360+
Founded
2012
Senior engineers
30+
Client CSAT
100%

Send a few lines about your product. A person from our team replies within one business day.

Start a projectScope it in Scope Studio
  • Emailcontact@apptension.com
  • Phone+48 533 352 052Poznań, Poland

  • Agentic MVP developmentNew
  • Agentic SDLC implementation
  • Product & SaaS development
  • Legacy modernization
  • Generative AI development
  • SaaS development company
  • Vibe-coded prototype to production
  • End-to-end software development
  • Senior engineering team extension
  • Product consulting & discovery
  • Tech due diligence for investors
  • All services

  • LLM application engineering
  • RAG & retrieval engineering
  • Voice AI agent development
  • MCP server development
  • LangGraph & LangChain agents
  • AI agent evaluation & observability
  • Node.js development company
  • Python & Django development
  • React & Next.js development
  • React Native app development
  • All expertise

  • Open-source SaaS Boilerplate
  • SaaS P&L model template
  • Walkthrough Studio
  • Agentic SDLC playbook
  • AI SDLC maturity assessment
  • Agentic SDLC ROI calculator
  • Founder resources
  • Events & exec dinners
  • Open source
  • Builder's Toolkit

  • Boutique vs large software house
  • Build vs buy vs partner
  • How to choose an AI & RAG partner
  • Team augmentation without chaos
  • Django vs Node.js for SaaS
  • React Native vs Flutter
  • AI in regulated industries
  • All guides

  • About Apptension
  • Case studies
  • Careers
  • Blog
  • Tech Radar
  • Agentic SDLC hub
  • Contact

Senior AI engineers shipping enterprise-grade AI and SaaS with startup speed.

Headquarters

Apptension sp. z o.o.23 Lutego 26
61-743 Poznań, Poland (opens Google Maps)

VAT-ID PL7831720203 · REGON 360404804
KRS 0000534235

Follow Apptension

Client reviews on Clutch

© 2012–2026 Apptension sp. z o.o. All rights reserved.

Privacy policySitemapllms.txt
Services
About
Portfolio
Careers
Blog
Get in touch
Technology
10 min read
February 29, 2024
Emil Litwiniec

From chaos to order: harness the power of Mock Factories

In frontend development, proficient mock management is indispensable for effective testing. We cover the pitfalls of poor mock handling and the remedies that keep it under control. Mocks play a vital role in simulating data and behaviors during testing. Good mock management improves both the application and the test suite. We'll explore solutions like the Mock Factory pattern, which makes mock management easier and enhances application resilience during testing.

From chaos to order: harness the power of Mock Factories

Into the void

Our recent project experienced rapid growth, with numerous developers joining the effort, leading to a surge in the daily creation of new components and corresponding unit tests. Each test required mock data, and initially, the creation of mocks was treated as a minor concern, resulting in their definition from scratch for each test suite. How a team handles test data like this has a direct effect on delivery quality as the codebase grows.

This approach seemed straightforward initially, given the dynamic and startup-like nature of the project's early stages, where practices were still evolving. However, this initial chaos led to a somewhat disorganized atmosphere, with a prevailing attitude of "we will figure it out later." And that's okay. The focus was rightly placed on addressing more critical aspects first. Minor issues could be deferred until there was ample resource capacity or until they began causing problems.

Soon, team members observed the proliferation of duplicated mocks throughout the project, prompting the idea to centralize them in a single location. Thus, creating the `mocks.ts` file was initiated, but its implementation fell short. While some mock objects were transferred there, they remained static, forcing developers to redefine mocks from scratch whenever specific edge cases required variations.

Unfortunately, the `mocks.ts` file grew into an unwieldy collection, encompassing mocks from various domains and teams. As single mock definitions expanded into multiple variants and larger datasets containing numerous entities, the file deviated from its original purpose, becoming a source of confusion rather than clarity.

It's important to note that all these mocks adhere to strict typing, derived from models generated from `openAPI`, which defines the contract between our front-end and back-end systems. Consequently, every mock must accurately reflect the current structure of the API to maintain consistency and ensure alignment between our application layers.

The approach to managing mocks was evidently flawed. While it served its purpose initially, its cumbersome nature became increasingly apparent as the codebase expanded and the API evolved. What once seemed functional and tolerable soon became unwieldy and challenging to maintain, highlighting the need for a more efficient solution.

When we requested the backend team to incorporate additional fields into our API response for a new feature, we anticipated a straightforward integration on the frontend. Adjusting a few lines seemed like a simple task. However, reality hit hard. Adding even a single new field to the model required modifications in nearly 100 files.

Many of these files were unaffected by the new field, yet they still needed adjustments to appease TypeScript errors. Each mock object, aligned with the modified model type, demanded manual updates for the new property-a time-consuming endeavor that nobody could afford. With the certainty of more API changes looming, we urgently needed to devise a swift and sustainable solution.

I'm beginning to see the light

__wf_reserved_inherit

Enter the Mock Factory pattern, our saving grace! In essence, it's a function designed to generate mock object based on a specified type. Easy to employ and highly adaptable, the Mock Factory simplifies the process of customizing mocks while ensuring a fresh object is returned with each invocation. Let's take a look at our mock factory creator.

Initialization couldn't be easier. Simply supply the type to the generic argument along with default data. You'll observe the use of `faker.js,` a tremendously helpful tool that furnishes meaningful content for our mocks. It also generates a unique ID each time, which matters for components that render data lists, for instance.

Using the mock is fairly intuitive. If necessary, we can override it with static data to accommodate specific test cases. Because the `getAccountMock` function is associated with the `Account` type, any attempts to add overrides will be flagged by TypeScript if they deviate from the defined type structure, helping to prevent errors before they occur.

And it's getting brighter

In most scenarios, this mock factory serves its purpose effectively. It provides a fresh mock for each use, allowing for easy overrides with specific values. However, there's room for enhancement. Currently, the factory generates a shallow copy with overrides, preventing the modification of individual properties within nested objects without replacing the entire object.

We can optimize the utility by opting for a deep-copy approach to address this limitation. As an option in our utility, we can use `merge` from `lodash` for this purpose. Given the resource-intensive nature of deep copy operations, this improvement ensures its usage only when necessary.

Imagine we've added more details to the `availableBalance` in our `Account` type. Now, we can easily adjust only the `currency` without redoing the whole `availableBalance.` This might seem simple, but it's incredibly useful for dealing with more complex data structures nested several levels deep.

Let it shine

__wf_reserved_inherit

Implementing this pattern demanded significant effort, particularly considering the prevailing technical debt. Nonetheless, the investment yielded substantial benefits. Consider the previous scenario where an API alteration required manual updates across 100 files. This laborious task was minimized to just a few: the type declaration, the default object definition within the mock factory, and the components using the new property.

Over time, the initial confusion disappeared, and the mocks embraced a structured organization. This not only streamlined the process but also facilitated swift access to mocks based on their API, obviating the need to retain them all within the notorious `mocks.ts.` I strongly recommend adopting this pattern early in a project. It not only enhances usability but also serves as documentation of your API, offering extra insights about your types.

>>>Ready to start your project?

Let's discuss how we can help bring your ideas to life.

Apptension site footer

Taking new projects

Have a product to build, fix or scale?

Apptension is a senior-only software development company headquartered in Poznań, Poland. Since 2012 our engineers have shipped 360+ AI and SaaS products for startups, scale-ups and enterprises across the US, UK and EU: agentic MVPs, RAG and voice AI systems, multi-tenant SaaS and legacy modernization.

Projects shipped
360+
Founded
2012
Senior engineers
30+
Client CSAT
100%

Send a few lines about your product. A person from our team replies within one business day.

Start a projectScope it in Scope Studio
  • Emailcontact@apptension.com
  • Phone+48 533 352 052Poznań, Poland

  • Agentic MVP developmentNew
  • Agentic SDLC implementation
  • Product & SaaS development
  • Legacy modernization
  • Generative AI development
  • SaaS development company
  • Vibe-coded prototype to production
  • End-to-end software development
  • Senior engineering team extension
  • Product consulting & discovery
  • Tech due diligence for investors
  • All services

  • LLM application engineering
  • RAG & retrieval engineering
  • Voice AI agent development
  • MCP server development
  • LangGraph & LangChain agents
  • AI agent evaluation & observability
  • Node.js development company
  • Python & Django development
  • React & Next.js development
  • React Native app development
  • All expertise

  • Open-source SaaS Boilerplate
  • SaaS P&L model template
  • Walkthrough Studio
  • Agentic SDLC playbook
  • AI SDLC maturity assessment
  • Agentic SDLC ROI calculator
  • Founder resources
  • Events & exec dinners
  • Open source
  • Builder's Toolkit

  • Boutique vs large software house
  • Build vs buy vs partner
  • How to choose an AI & RAG partner
  • Team augmentation without chaos
  • Django vs Node.js for SaaS
  • React Native vs Flutter
  • AI in regulated industries
  • All guides

  • About Apptension
  • Case studies
  • Careers
  • Blog
  • Tech Radar
  • Agentic SDLC hub
  • Contact

Senior AI engineers shipping enterprise-grade AI and SaaS with startup speed.

Headquarters

Apptension sp. z o.o.23 Lutego 26
61-743 Poznań, Poland (opens Google Maps)

VAT-ID PL7831720203 · REGON 360404804
KRS 0000534235

Follow Apptension

Client reviews on Clutch

© 2012–2026 Apptension sp. z o.o. All rights reserved.

Privacy policySitemapllms.txt