Socket
Socket
Sign inDemoInstall

data-test-name

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    data-test-name

> Helpers for clean and maintainable selectors in browser (end-to-end, puppeteer) tests


Version published
Maintainers
1
Created

Readme

Source

data-test-name

Helpers for clean and maintainable selectors in browser (end-to-end, puppeteer) tests

Build Status Coverage Status

Example

// test.js
import { selector } from 'data-test-name';

const loginForm = selector('login');

await page.waitFor(loginForm());
await page.type(selector(loginForm, 'email')(), 'user@example.com');
await page.type(selector(loginForm, 'password')(), 'secret');
await page.click(selector(loginForm, 'submit')());
// LoginForm.jsx

export const LoginForm = ({ onSubmit }) => (
	<form
		onSubmit={onSubmit}
		data-test-name="login"
	>
		<input
			type="email"
			data-test-name="email"
		/>

		<input
			type="password"
			data-test-name="password"
		/>

		<button
			type="submit"
			data-test-name="submit"
		>
	</form>
);

Why

When selectors in your tests do not use classnames, ids or names, you can easily change styles, swap commponents, etc. without breaking the tests. Just keep the same data-test-name values.

Install

yarn add --dev data-test-name

Keywords

FAQs

Last updated on 28 Oct 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc