Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pptr-testing-library

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pptr-testing-library - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

2

dist/index.d.ts

@@ -5,3 +5,3 @@ import { ElementHandle, Page } from 'puppeteer';

export declare function getDocument(_page?: Page): Promise<ElementHandle>;
export declare function wait(callback?: () => any, { timeout, interval }?: {
export declare function wait(callback: () => void, { timeout, interval }?: {
timeout?: number;

@@ -8,0 +8,0 @@ interval?: number;

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -93,3 +94,3 @@ });

if (containerHandle === args[0]) {
argsToForward = args.slice(1);
argsToForward = argsToForward.slice(1);
}

@@ -112,3 +113,3 @@ return processHandleFn({ fnName, containerHandle, evaluateFn, argsToForward });

exports.getDocument = getDocument;
function wait(callback = () => undefined, { timeout = 4500, interval = 50 } = {}) {
function wait(callback, { timeout = 4500, interval = 50 } = {}) {
return wait_for_expect_1.default(callback, timeout, interval);

@@ -121,35 +122,40 @@ }

contextFn = () => o;
const functionNames = [
'queryByPlaceholderText',
'queryAllByPlaceholderText',
'getByPlaceholderText',
'getAllByPlaceholderText',
'queryByText',
'queryAllByText',
'getByText',
'getAllByText',
'queryByLabelText',
'queryAllByLabelText',
'getByLabelText',
'getAllByLabelText',
'queryByAltText',
'queryAllByAltText',
'getByAltText',
'getAllByAltText',
'queryByTestId',
'queryAllByTestId',
'getByTestId',
'getAllByTestId',
'queryByTitle',
'queryAllByTitle',
'getByTitle',
'getAllByTitle',
'queryByRole',
'queryAllByRole',
'getByRole',
'getAllByRole',
'queryByDisplayValue',
'queryAllByDisplayValue',
'getByDisplayValue',
'getAllByDisplayValue',
];
functionNames.forEach(functionName => {
o[functionName] = createDelegateFor(functionName, contextFn);
});
o.getQueriesForElement = () => getQueriesForElement(o, () => o);
o.queryByPlaceholderText = createDelegateFor('queryByPlaceholderText', contextFn);
o.queryAllByPlaceholderText = createDelegateFor('queryAllByPlaceholderText', contextFn);
o.getByPlaceholderText = createDelegateFor('getByPlaceholderText', contextFn);
o.getAllByPlaceholderText = createDelegateFor('getAllByPlaceholderText', contextFn);
o.queryByText = createDelegateFor('queryByText', contextFn);
o.queryAllByText = createDelegateFor('queryAllByText', contextFn);
o.getByText = createDelegateFor('getByText', contextFn);
o.getAllByText = createDelegateFor('getAllByText', contextFn);
o.queryByLabelText = createDelegateFor('queryByLabelText', contextFn);
o.queryAllByLabelText = createDelegateFor('queryAllByLabelText', contextFn);
o.getByLabelText = createDelegateFor('getByLabelText', contextFn);
o.getAllByLabelText = createDelegateFor('getAllByLabelText', contextFn);
o.queryByAltText = createDelegateFor('queryByAltText', contextFn);
o.queryAllByAltText = createDelegateFor('queryAllByAltText', contextFn);
o.getByAltText = createDelegateFor('getByAltText', contextFn);
o.getAllByAltText = createDelegateFor('getAllByAltText', contextFn);
o.queryByTestId = createDelegateFor('queryByTestId', contextFn);
o.queryAllByTestId = createDelegateFor('queryAllByTestId', contextFn);
o.getByTestId = createDelegateFor('getByTestId', contextFn);
o.getAllByTestId = createDelegateFor('getAllByTestId', contextFn);
o.queryByTitle = createDelegateFor('queryByTitle', contextFn);
o.queryAllByTitle = createDelegateFor('queryAllByTitle', contextFn);
o.getByTitle = createDelegateFor('getByTitle', contextFn);
o.getAllByTitle = createDelegateFor('getAllByTitle', contextFn);
o.queryByRole = createDelegateFor('queryByRole', contextFn);
o.queryAllByRole = createDelegateFor('queryAllByRole', contextFn);
o.getByRole = createDelegateFor('getByRole', contextFn);
o.getAllByRole = createDelegateFor('getAllByRole', contextFn);
o.queryByDisplayValue = createDelegateFor('queryByDisplayValue', contextFn);
o.queryAllByDisplayValue = createDelegateFor('queryAllByDisplayValue', contextFn);
o.getByDisplayValue = createDelegateFor('getByDisplayValue', contextFn);
o.getAllByDisplayValue = createDelegateFor('getAllByDisplayValue', contextFn);
o.getNodeText = createDelegateFor('getNodeText', contextFn, processNodeText);

@@ -156,0 +162,0 @@ return o;

@@ -1,2 +0,2 @@

import { Matcher, MatcherOptions, SelectorMatcherOptions } from 'dom-testing-library/typings';
import { Matcher, MatcherOptions, SelectorMatcherOptions } from '@testing-library/dom';
import { ElementHandle } from 'puppeteer';

@@ -3,0 +3,0 @@ declare type Element = ElementHandle;

@@ -0,3 +1,4 @@

import {ElementHandle} from 'puppeteer'
import {getDocument, getQueriesForElement} from '.'
import {ElementHandle} from '../node_modules/@types/puppeteer'
import {IScopedQueryUtils} from './typedefs'

@@ -4,0 +5,0 @@

@@ -5,2 +5,3 @@ import {readFileSync} from 'fs'

import waitForExpect from 'wait-for-expect'
import {IQueryUtils, IScopedQueryUtils} from './typedefs'

@@ -36,3 +37,3 @@

const lengthHandle = await handle.getProperty('length')
const length = await lengthHandle.jsonValue()
const length = await lengthHandle.jsonValue() as number

@@ -111,3 +112,3 @@ const elements: ElementHandle[] = []

if (containerHandle === args[0]) {
argsToForward = args.slice(1)
argsToForward = argsToForward.slice(1)
}

@@ -129,4 +130,4 @@

export function wait(
callback: () => any = () => undefined,
{timeout = 4500, interval = 50} = {}, // tslint:disable-line
callback: () => void,
{timeout = 4500, interval = 50}: {timeout?: number; interval?: number} = {},
): Promise<{}> {

@@ -142,44 +143,49 @@ return waitForExpect(callback, timeout, interval)

if (!contextFn) contextFn = () => o
o.getQueriesForElement = () => getQueriesForElement(o, () => o)
o.queryByPlaceholderText = createDelegateFor('queryByPlaceholderText', contextFn)
o.queryAllByPlaceholderText = createDelegateFor('queryAllByPlaceholderText', contextFn)
o.getByPlaceholderText = createDelegateFor('getByPlaceholderText', contextFn)
o.getAllByPlaceholderText = createDelegateFor('getAllByPlaceholderText', contextFn)
const functionNames: Array<keyof IQueryUtils> = [
'queryByPlaceholderText',
'queryAllByPlaceholderText',
'getByPlaceholderText',
'getAllByPlaceholderText',
o.queryByText = createDelegateFor('queryByText', contextFn)
o.queryAllByText = createDelegateFor('queryAllByText', contextFn)
o.getByText = createDelegateFor('getByText', contextFn)
o.getAllByText = createDelegateFor('getAllByText', contextFn)
'queryByText',
'queryAllByText',
'getByText',
'getAllByText',
o.queryByLabelText = createDelegateFor('queryByLabelText', contextFn)
o.queryAllByLabelText = createDelegateFor('queryAllByLabelText', contextFn)
o.getByLabelText = createDelegateFor('getByLabelText', contextFn)
o.getAllByLabelText = createDelegateFor('getAllByLabelText', contextFn)
'queryByLabelText',
'queryAllByLabelText',
'getByLabelText',
'getAllByLabelText',
o.queryByAltText = createDelegateFor('queryByAltText', contextFn)
o.queryAllByAltText = createDelegateFor('queryAllByAltText', contextFn)
o.getByAltText = createDelegateFor('getByAltText', contextFn)
o.getAllByAltText = createDelegateFor('getAllByAltText', contextFn)
'queryByAltText',
'queryAllByAltText',
'getByAltText',
'getAllByAltText',
o.queryByTestId = createDelegateFor('queryByTestId', contextFn)
o.queryAllByTestId = createDelegateFor('queryAllByTestId', contextFn)
o.getByTestId = createDelegateFor('getByTestId', contextFn)
o.getAllByTestId = createDelegateFor('getAllByTestId', contextFn)
'queryByTestId',
'queryAllByTestId',
'getByTestId',
'getAllByTestId',
o.queryByTitle = createDelegateFor('queryByTitle', contextFn)
o.queryAllByTitle = createDelegateFor('queryAllByTitle', contextFn)
o.getByTitle = createDelegateFor('getByTitle', contextFn)
o.getAllByTitle = createDelegateFor('getAllByTitle', contextFn)
'queryByTitle',
'queryAllByTitle',
'getByTitle',
'getAllByTitle',
o.queryByRole = createDelegateFor('queryByRole', contextFn)
o.queryAllByRole = createDelegateFor('queryAllByRole', contextFn)
o.getByRole = createDelegateFor('getByRole', contextFn)
o.getAllByRole = createDelegateFor('getAllByRole', contextFn)
'queryByRole',
'queryAllByRole',
'getByRole',
'getAllByRole',
o.queryByDisplayValue = createDelegateFor('queryByDisplayValue', contextFn)
o.queryAllByDisplayValue = createDelegateFor('queryAllByDisplayValue', contextFn)
o.getByDisplayValue = createDelegateFor('getByDisplayValue', contextFn)
o.getAllByDisplayValue = createDelegateFor('getAllByDisplayValue', contextFn)
'queryByDisplayValue',
'queryAllByDisplayValue',
'getByDisplayValue',
'getAllByDisplayValue',
]
functionNames.forEach(functionName => {
o[functionName] = createDelegateFor(functionName, contextFn)
})
o.getQueriesForElement = () => getQueriesForElement(o, () => o)
o.getNodeText = createDelegateFor<string>('getNodeText', contextFn, processNodeText)

@@ -186,0 +192,0 @@

@@ -1,2 +0,2 @@

import {Matcher, MatcherOptions, SelectorMatcherOptions} from 'dom-testing-library/typings' // tslint:disable-line no-submodule-imports
import {Matcher, MatcherOptions, SelectorMatcherOptions} from '@testing-library/dom'
import {ElementHandle} from 'puppeteer'

@@ -3,0 +3,0 @@

{
"name": "pptr-testing-library",
"version": "0.5.0",
"version": "0.6.0",
"description": "puppeteer + dom-testing-library",

@@ -31,2 +31,3 @@ "main": "./dist/index.js",

"dom-testing-library",
"testing-library",
"testing",

@@ -38,3 +39,16 @@ "utility"

"rules": {
"no-unsafe-any": false
"increment-decrement": false,
"no-unsafe-any": false,
"ban-ts-ignore": {
"severity": "warning"
},
"function-constructor": {
"severity": "warning"
},
"strict-comparisons": {
"severity": "warning"
},
"match-default-export-name": {
"severity": "warning"
}
}

@@ -47,7 +61,10 @@ },

"dependencies": {
"dom-testing-library": "^4.1.1",
"wait-for-expect": "^1.2.0"
"@testing-library/dom": "^7.0.4",
"wait-for-expect": "^3.0.2"
},
"devDependencies": {
"@patrickhulce/lint": "^2.1.3",
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-node-resolve": "^7.1.1",
"@rollup/plugin-replace": "^2.3.1",
"@types/jest": "^25.1.4",

@@ -58,9 +75,6 @@ "@types/puppeteer": "^2.0.0",

"puppeteer": "^2.0.0",
"rollup": "^0.61.1",
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-replace": "^2.2.0",
"ts-jest": "^22.4.6",
"tslint": "^5.10.0",
"typescript": "^2.9.2"
"rollup": "^2.0.3",
"ts-jest": "^25.2.1",
"tslint": "^6.0.0",
"typescript": "^3.8.3"
},

@@ -71,4 +85,4 @@ "peerDependencies": {

"engines": {
"node": "^10 || ^12"
"node": "^10 || ^12 || ^13"
}
}

@@ -8,5 +8,5 @@ # pptr-testing-library

[puppeteer](https://github.com/GoogleChrome/puppeteer) + [dom-testing-library](https://github.com/testing-library/dom-testing-library) = 💖
[puppeteer](https://github.com/GoogleChrome/puppeteer) + [@testing-library/dom](https://github.com/testing-library/dom-testing-library) = 💖
All your favorite user-centric querying functions from react-testing-library/dom-testing-library available from Puppeteer!
All your favorite user-centric querying functions from @testing-library/react & @testing-library/library available from Puppeteer!

@@ -60,14 +60,14 @@ ## Install

Unique methods, not part of `dom-testing-library`
Unique methods, not part of `@testing-library/dom`
- `getDocument(page: puppeteer.Page): ElementHandle` - get an ElementHandle for the document
- `wait(conditionFn: () => {}): Promise<{}>` - wait for the condition to not throw (wrapper around `waitForExpect`)
---
[dom-testing-libary API](https://github.com/testing-library/dom-testing-library#usage). All `get*`/`query*` methods are supported.
[@testing-library/dom API](https://github.com/testing-library/dom-testing-library#usage). All `get*`/`query*` methods are supported.
- `getQueriesForElement(handle: ElementHandle): ElementHandle & QueryUtils` - extend the input object with the query API and return it
- `wait(conditionFn: () => {}): Promise<{}>` - wait for the condition to not throw
- `getNodeText(handle: ElementHandle): Promise<string>` - get the text content of the element
- `queries: QueryUtils` - the query subset of `dom-testing-library` exports
- `queries: QueryUtils` - the query subset of `@testing-library/dom` exports
- `queryByPlaceholderText`

@@ -100,3 +100,3 @@ - `queryAllByPlaceholderText`

- `waitForElement` method is not exposed. Puppeteer has its own set of wait utilities that somewhat conflict with the style used in `dom-testing-library`. See [#3](https://github.com/testing-library/pptr-testing-library/issues/3).
- `waitForElement` method is not exposed. Puppeteer has its own set of wait utilities that somewhat conflict with the style used in `@testing-library/dom`. See [#3](https://github.com/testing-library/pptr-testing-library/issues/3).
- `fireEvent` method is not exposed, use puppeteer's built-ins instead.

@@ -107,3 +107,3 @@ - `expect` assertion extensions are not available.

[dom-testing-library](https://github.com/testing-library/dom-testing-library) of course!
[@testing-library/dom](https://github.com/testing-library/dom-testing-library) of course!

@@ -110,0 +110,0 @@ ## Related Puppeteer Test Utilities

@@ -1,2 +0,5 @@

const path = require('path')
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import replace from '@rollup/plugin-replace'
import path from 'path'

@@ -11,5 +14,5 @@ module.exports = {

plugins: [
require('rollup-plugin-node-resolve')(),
require('rollup-plugin-commonjs')(),
require('rollup-plugin-replace')({
resolve(),
commonjs(),
replace({
'process.env.NODE_ENV': JSON.stringify('development'),

@@ -16,0 +19,0 @@ }),

@@ -1,2 +0,2 @@

export * from 'dom-testing-library/dist/queries'
export {getNodeText} from 'dom-testing-library/dist/get-node-text'
export * from '@testing-library/dom/dist/queries'
export {getNodeText} from '@testing-library/dom'

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc