![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@smartbear/visualtest-playwright
Advanced tools
Playwright Plugin for SmartBear VisualTest via TypeScript/JavaScript
Click here for more detailed docs on SmartBear's website
npm install @smartbear/visualtest-playwright --save-dev
npx visualtest-setup
Enter your projectToken in the newly created visualTest.config.js
file:
module.exports = {projectToken: 'PROJECT_TOKEN'}
import {sbvtCapture, sbvtGetTestRunResult, sbvtPrintReport} from "@smartbear/visualtest-playwright";
import {expect, test} from "@playwright/test";
test(`should visit Playwright example page, then take sbvtCaptures`, async ({page}) => {
await page.goto('https://playwright.dev/')
await sbvtCapture(page, 'Playwright Example Page')
await sbvtCapture(page, 'element', {
elementCapture: ".hero"
});
await sbvtCapture(page, 'Homepage viewport', {
viewport: true
})
await sbvtPrintReport(); //print out the results of the comparison
const sbvtReport = await sbvtGetTestRunResult();
expect(sbvtReport.failed).toEqual(0); //assert for no comparison differences
})
test('test taking an element sbvt capture', async ({page}) => {
await page.goto('https://smartbear.github.io/visual-testing-example-website/Example4/Original/index.html');
await sbvtCapture(page, 'fullpage-capture',
{
lazyload: 250,
});
});
test('take a viewport snapshot', async ({page}) => {
await page.goto('https://smartbear.com');
await sbvtCapture(page, 'sb-viewport', {
viewport: true
});
});
test('take an element sbvt capture', async ({page}) => {
await page.goto('https://smartbear.github.io/visual-testing-example-website/Example4/Original/index.html');
await sbvtCapture(page, 'element-hero-content-capture', {
elementCapture: ".ud-hero-content"
});
});
test('ignore element sbvt capture', async ({page}) => {
await page.goto('https://smartbear.github.io/visual-testing-example-website/Example4/Original/index.html');
await sbvtCapture(page, 'element-hero-content-capture', {
ignoreElements: [".ud-hero-content"], //input CSS selectors as an array
lazyload: 250
});
});
test('layout mode comparison', async ({page}) => {
await page.goto('https://smartbear.github.io/visual-testing-example-website/Example4/Original/index.html');
await sbvtCapture(page, 'layout-mode', {
comparisonMode: 'layout',
sensitivity: 'low', // 'medium', or 'high'
});
});
test('test taking an element sbvt capture', async ({page}) => {
await page.goto('https://smartbear.github.io/visual-testing-example-website/Example4/Original/index.html');
await sbvtCapture(page, 'fullpage-capture', {
lazyload: 250,
});
const testRunResults = await sbvtGetTestRunResult() //testRunResults will have the pass/fail data on it incase you want to fail the run on a comparison failure
await sbvtPrintReport() // prints the comparison data for the test run
});
test('test creating a pdf and then checking the a key value pair', async ({page}) => {
await page.goto('https://smartbear.github.io/visual-testing-example-website/Example4/Original/index.html');
const pdf = await page.pdf();
const pdfKeyValuePairs = (await sbvtSendFile(pdf, 'file-name'))
console.log('KVPs: ',pdfKeyValuePairs);
expect(pdfKeyValuePairs["New User"]).toEqual('34567');
});
//visualtest.config.js
module.exports = {
projectToken: 'PROJECT_TOKEN',
testGroupName: 'test group name'
}
// OR save on the environment variable
// SBVT_TEST_GROUP_NAME = 'test group name'
Each worker process does not communicate with the other workers, this causes separate testRuns and makes grouping all the images into one testRun tough. To alleviate this, add the below line to your playwright.config
file
//playwright.config
module.exports = defineConfig({
globalSetup: '@smartbear/visualtest-playwright',
// rest of your configurations
});
Save Source Control Manager data on the environment variable
SBVT_SCM_BRANCH=branch-name
SBVT_SCM_COMMIT_ID=commit-hash
FAQs
Playwright Plugin for SmartBear VisualTest via TypeScript/JavaScript
The npm package @smartbear/visualtest-playwright receives a total of 17 weekly downloads. As such, @smartbear/visualtest-playwright popularity was classified as not popular.
We found that @smartbear/visualtest-playwright demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.