Entertainer.newsEntertainer.news
  • Home
  • Celebrity
  • Movies
  • Music
  • Web Series
  • Podcast
  • OTT
  • Television
  • Interviews
  • Awards

Subscribe to Updates

Get the latest Entertainment News and Updates from Entertainer News

What's Hot

Tom Hanks’ wife Rita Wilson reveals shocking family secret her father left behind

April 23, 2026

Chicago Fire’s Hanako Greensmith, Jocelyn Hudon Talk Violet/Novak Love Triangle

April 23, 2026

When You Give A Child Caffeine… | Perez Hilton

April 23, 2026
Facebook Twitter Instagram
Thursday, April 23
  • About us
  • Advertise with us
  • Submit Articles
  • Privacy Policy
  • Contact us
Facebook Twitter Tumblr LinkedIn
Entertainer.newsEntertainer.news
Subscribe Login
  • Home
  • Celebrity
  • Movies
  • Music
  • Web Series
  • Podcast
  • OTT
  • Television
  • Interviews
  • Awards
Entertainer.newsEntertainer.news
Home Introducing SafeTest: A Novel Approach to Front End Testing | by Netflix Technology Blog | Feb, 2024
Web Series

Introducing SafeTest: A Novel Approach to Front End Testing | by Netflix Technology Blog | Feb, 2024

Team EntertainerBy Team EntertainerFebruary 13, 2024Updated:February 15, 2024No Comments9 Mins Read
Facebook Twitter Pinterest LinkedIn Tumblr WhatsApp VKontakte Email
Introducing SafeTest: A Novel Approach to Front End Testing | by Netflix Technology Blog | Feb, 2024
Share
Facebook Twitter LinkedIn Pinterest Email


Netflix Technology Blog
Netflix TechBlog

by Moshe Kolodny

On this publish, we’re excited to introduce SafeTest, a revolutionary library that provides a contemporary perspective on Finish-To-Finish (E2E) checks for web-based Person Interface (UI) functions.

Historically, UI checks have been performed by both unit testing or integration testing (additionally known as Finish-To-Finish (E2E) testing). Nonetheless, every of those strategies presents a singular trade-off: you need to select between controlling the take a look at fixture and setup, or controlling the take a look at driver.

For example, when utilizing react-testing-library, a unit testing answer, you keep full management over what to render and the way the underlying providers and imports ought to behave. Nonetheless, you lose the flexibility to work together with an precise web page, which might result in a myriad of ache factors:

  • Problem in interacting with complicated UI components like <Dropdown /> parts.
  • Lack of ability to check CORS setup or GraphQL calls.
  • Lack of visibility into z-index points affecting click-ability of buttons.
  • Complicated and unintuitive authoring and debugging of checks.

Conversely, utilizing integration testing instruments like Cypress or Playwright gives management over the web page, however sacrifices the flexibility to instrument the bootstrapping code for the app. These instruments function by remotely controlling a browser to go to a URL and work together with the web page. This strategy has its personal set of challenges:

  • Problem in making calls to another API endpoint with out implementing customized community layer API rewrite guidelines.
  • Lack of ability to make assertions on spies/mocks or execute code inside the app.
  • Testing one thing like darkish mode entails clicking the theme switcher or figuring out the localStorage mechanism to override.
  • Lack of ability to check segments of the app, for instance if a element is just seen after clicking a button and ready for a 60 second timer to countdown, the take a look at might want to run these actions and will likely be at the least a minute lengthy.

Recognizing these challenges, options like E2E Element Testing have emerged, with choices from Cypress and Playwright. Whereas these instruments try and rectify the shortcomings of conventional integration testing strategies, they produce other limitations because of their structure. They begin a dev server with bootstrapping code to load the element and/or setup code you need, which limits their means to deal with complicated enterprise functions which may have OAuth or a fancy construct pipeline. Furthermore, updating TypeScript utilization might break your checks till the Cypress/Playwright staff updates their runner.

SafeTest goals to deal with these points with a novel strategy to UI testing. The principle thought is to have a snippet of code in our software bootstrapping stage that injects hooks to run our checks (see the How Safetest Works sections for more information on what that is doing). Observe that how this works has no measurable impression on the common utilization of your app since SafeTest leverages lazy loading to dynamically load the checks solely when operating the checks (within the README instance, the checks aren’t within the manufacturing bundle in any respect). As soon as that’s in place, we are able to use Playwright to run common checks, thereby attaining the perfect browser management we wish for our checks.

This strategy additionally unlocks some thrilling options:

  • Deep linking to a selected take a look at without having to run a node take a look at server.
  • Two-way communication between the browser and take a look at (node) context.
  • Entry to all of the DX options that include Playwright (excluding those that include @playwright/take a look at).
  • Video recording of checks, hint viewing, and pause web page performance for making an attempt out totally different web page selectors/actions.
  • Capacity to make assertions on spies within the browser in node, matching snapshot of the decision inside the browser.

SafeTest is designed to really feel acquainted to anybody who has performed UI checks earlier than, because it leverages the perfect elements of current options. Right here’s an instance of the way to take a look at a whole software:

import { describe, it, anticipate } from 'safetest/jest';
import { render } from 'safetest/react';

describe('my app', () => {
it('masses the principle web page', async () => {
const { web page } = await render();

await anticipate(web page.getByText('Welcome to the app')).toBeVisible();
anticipate(await web page.screenshot()).toMatchImageSnapshot();
});
});

We are able to simply as simply take a look at a selected element

import { describe, it, anticipate, browserMock } from 'safetest/jest';
import { render } from 'safetest/react';

describe('Header element', () => {
it('has a traditional mode', async () => {
const { web page } = await render(<Header />);

await anticipate(web page.getByText('Admin')).not.toBeVisible();
});

it('has an admin mode', async () => {
const { web page } = await render(<Header admin={true} />);

await anticipate(web page.getByText('Admin')).toBeVisible();
});

it('calls the logout handler when signing out', async () => {
const spy = browserMock.fn();
const { web page } = await render(<Header handleLogout={fn} />);

await web page.getByText('logout').click on();
anticipate(await spy).toHaveBeenCalledWith();
});
});

SafeTest makes use of React Context to permit for worth overrides throughout checks. For an instance of how this works, let’s assume we’ve got a fetchPeople operate utilized in a element:

import { useAsync } from 'react-use';
import { fetchPerson } from './api/particular person';

export const Folks: React.FC = () => {
const { knowledge: folks, loading, error } = useAsync(fetchPeople);

if (loading) return <Loader />;
if (error) return <ErrorPage error={error} />;
return <Desk knowledge={knowledge} rows=[...] />;
}

We are able to modify the Folks element to make use of an Override:

 import { fetchPerson } from './api/particular person';
+import { createOverride } from 'safetest/react';

+const FetchPerson = createOverride(fetchPerson);

export const Folks: React.FC = () => {
+ const fetchPeople = FetchPerson.useValue();
const { knowledge: folks, loading, error } = useAsync(fetchPeople);

if (loading) return <Loader />;
if (error) return <ErrorPage error={error} />;
return <Desk knowledge={knowledge} rows=[...] />;
}

Now, in our take a look at, we are able to override the response for this name:

const pending = new Promise(r => { /* Do nothing */ });
const resolved = [{name: 'Foo', age: 23], {identify: 'Bar', age: 32]}];
const error = new Error('Whoops');

describe('Folks', () => {
it('has a loading state', async () => {
const { web page } = await render(
<FetchPerson.Override with={() => () => pending}>
<Folks />
</FetchPerson.Override>
);

await anticipate(web page.getByText('Loading')).toBeVisible();
});

it('has a loaded state', async () => {
const { web page } = await render(
<FetchPerson.Override with={() => async () => resolved}>
<Folks />
</FetchPerson.Override>
);

await anticipate(web page.getByText('Person: Foo, identify: 23')).toBeVisible();
});

it('has an error state', async () => {
const { web page } = await render(
<FetchPerson.Override with={() => async () => { throw error }}>
<Folks />
</FetchPerson.Override>
);

await anticipate(web page.getByText('Error getting customers: "Whoops"')).toBeVisible();
});
});

The render operate additionally accepts a operate that will likely be handed the preliminary app element, permitting for the injection of any desired components wherever within the app:

it('has a folks loaded state', async () => {
const { web page } = await render(app =>
<FetchPerson.Override with={() => async () => resolved}>
{app}
</FetchPerson.Override>
);
await anticipate(web page.getByText('Person: Foo, identify: 23')).toBeVisible();
});

With overrides, we are able to write complicated take a look at instances similar to making certain a service technique which mixes API requests from /foo, /bar, and /baz, has the proper retry mechanism for simply the failed API requests and nonetheless maps the return worth appropriately. So if /bar takes 3 makes an attempt to resolve the tactic will make a complete of 5 API calls.

Overrides aren’t restricted to only API calls (since we are able to use additionally use web page.route), we are able to additionally override particular app stage values like function flags or altering some static worth:

+const UseFlags = createOverride(useFlags);
export const Admin = () => {
+ const useFlags = UseFlags.useValue();
const { isAdmin } = useFlags();
if (!isAdmin) return <div>Permission error</div>;
// ...
}

+const Language = createOverride(navigator.language);
export const LanguageChanger = () => {
- const language = navigator.language;
+ const language = Language.useValue();
return <div>Present language is { language } </div>;
}

describe('Admin', () => {
it('works with admin flag', async () => {
const { web page } = await render(
<UseIsAdmin.Override with={oldHook => {
const oldFlags = oldHook();
return { ...oldFlags, isAdmin: true };
}}>
<MyComponent />
</UseIsAdmin.Override>
);

await anticipate(web page.getByText('Permission error')).not.toBeVisible();
});
});

describe('Language', () => {
it('shows', async () => {
const { web page } = await render(
<Language.Override with={outdated => 'abc'}>
<MyComponent />
</Language.Override>
);

await anticipate(web page.getByText('Present language is abc')).toBeVisible();
});
});

Overrides are a robust function of SafeTest and the examples right here solely scratch the floor. For extra data and examples, discuss with the Overrides part on the README.

SafeTest comes out of the field with highly effective reporting capabilities, similar to computerized linking of video replays, Playwright hint viewer, and even deep hyperlink on to the mounted examined element. The SafeTest repo README hyperlinks to all the instance apps in addition to the studies

Image of SafeTest report showing a video of a test run

Many giant firms want a type of authentication to make use of the app. Sometimes, navigating to localhost:3000 simply ends in a perpetually loading web page. It’s good to go to a unique port, like localhost:8000, which has a proxy server to verify and/or inject auth credentials into underlying service calls. This limitation is likely one of the most important causes that Cypress/Playwright Element Checks aren’t appropriate to be used at Netflix.

Nonetheless, there’s normally a service that may generate take a look at customers whose credentials we are able to use to log in and work together with the appliance. This facilitates creating a light-weight wrapper round SafeTest to routinely generate and assume that take a look at consumer. For example, right here’s mainly how we do it at Netflix:

import { setup } from 'safetest/setup';
import { createTestUser, addCookies } from 'netflix-test-helper';

kind Setup = Parameters<typeof setup>[0] & {
extraUserOptions?: UserOptions;
};

export const setupNetflix = (choices: Setup) => {
setup({
...choices,
hooks: { beforeNavigate: [async page => addCookies(page)] },
});

beforeAll(async () => {
createTestUser(choices.extraUserOptions)
});
};

After setting this up, we merely import the above bundle rather than the place we’d have used safetest/setup.

Whereas this publish centered on how SafeTest works with React, it’s not restricted to only React. SafeTest additionally works with Vue, Svelte, Angular, and even can run on NextJS or Gatsby. It additionally runs utilizing both Jest or Vitest primarily based on which take a look at runner your scaffolding began you off with. The examples folder demonstrates the way to use SafeTest with totally different tooling combos, and we encourage contributions so as to add extra instances.

At its core, SafeTest is an clever glue for a take a look at runner, a UI library, and a browser runner. Although the commonest utilization at Netflix employs Jest/React/Playwright, it’s simple so as to add extra adapters for different choices.

SafeTest is a robust testing framework that’s being adopted inside Netflix. It permits for simple authoring of checks and gives complete studies when and the way any failures occurred, full with hyperlinks to view a playback video or manually run the take a look at steps to see what broke. We’re excited to see the way it will revolutionize UI testing and stay up for your suggestions and contributions.



Source link

approach Blog Feb Front Introducing Netflix SafeTest Technology Testing
Share. Facebook Twitter Pinterest LinkedIn Tumblr WhatsApp Email
Previous ArticleOfficial Oscar Night Fun Doesn’t Come Cheap At Academy Museum
Next Article Andy Cohen Hopes to ‘Get the Tea’ About Marcus Jordan, Larsa Pippen’s Split
Team Entertainer
  • Website

Related Posts

Wednesday Season 3 Photo Gives First Look at Jenna Ortega in Netflix Return

April 21, 2026

The Human Infrastructure: How Netflix Built the Operations Layer Behind Live at Scale | by Netflix Technology Blog | Apr, 2026

April 17, 2026

10 Actors Who Owe Their Careers to Netflix

April 17, 2026

Premiere Date, Cast, and More on Netflix Series

April 12, 2026
Recent Posts
  • Tom Hanks’ wife Rita Wilson reveals shocking family secret her father left behind
  • Chicago Fire’s Hanako Greensmith, Jocelyn Hudon Talk Violet/Novak Love Triangle
  • When You Give A Child Caffeine… | Perez Hilton
  • Michael Jackson’s 95-Year-Old Mom Katherine Seen In Rare Pic Ahead Of Michael Premiere!

Archives

  • April 2026
  • March 2026
  • February 2026
  • January 2026
  • December 2025
  • November 2025
  • October 2025
  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021

Categories

  • Actress
  • Awards
  • Behind the Camera
  • BollyBuzz
  • Celebrity
  • Edit Picks
  • Glam & Style
  • Global Bollywood
  • In the Frame
  • Insta Inspector
  • Interviews
  • Movies
  • Music
  • News
  • News & Gossip
  • News & Gossips
  • OTT
  • Podcast
  • Power & Purpose
  • Press Release
  • Spotlight Stories
  • Spotted!
  • Star Luxe
  • Television
  • Trending
  • Uncategorized
  • Web Series
NAVIGATION
  • About us
  • Advertise with us
  • Submit Articles
  • Privacy Policy
  • Contact us
  • About us
  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us
Copyright © 2026 Entertainer.

Type above and press Enter to search. Press Esc to cancel.

Sign In or Register

Welcome Back!

Login to your account below.

Lost password?