0

JS 测试文件。只是尝试运行一个非常基本的 percy 测试来生成快照,我假设它是在线上传的。

const puppeteer = require('puppeteer');
const percySnapshot = require('@percy/puppeteer');

describe('Percy Visual Test', () => {
    let browser;
    let page;

    beforeAll(async function () {
        browser = await puppeteer.launch({
            headless: true,
        });
        page = await browser.newPage();
    });

    afterAll(async function () {
        await browser.close();
    });

    test('Full Page Percy Snapshot', async () => {
        await page.goto('https://www.example.com');
        await page.waitForTimeout(1000);
        await percySnapshot(page, 'Example Page');
    });
});

package.json (我正在使用命令 npm run test:percy

"scripts": {
        "test-snapshots": "jest --config=jest.config.js --detectOpenHandles --forceExit",
        "test-snapshots-update": "jest --config=jest.config.js --updateSnapshot --detectOpenHandles --forceExit",
        "test:percy": "percy exec -- jest -i ./tests-snapshots/__tests__/percy.test.js"
    },
    "author": "",
    "license": "ISC",
    "dependencies": {
        "@percy/puppeteer": "^1.1.0",
        "jest": "^26.6.3",
        "jest-image-snapshot": "^4.5.0",
        "prettier": "^2.3.0",
        "puppeteer": "^9.1.1"
    }

下面的错误信息。我的测试脚本命令有问题吗?遵循 Udemy 教程。在窗户上工作。PS为终端。

> percy exec -- jest -i './tests-snapshots/__tests__/__image_snapshots__/percy.test.js'

[percy] created build #3: https://percy.io/<>
[percy] percy has started.
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In C:\Users\<>\Desktop\Udemy\Puppeteer\pptr-visual\tests-snapshots
  2 files checked.
  testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 2 matches
  testPathIgnorePatterns: \\node_modules\\ - 2 matches
  testRegex:  - 0 matches
Pattern: '.\\tests-snapshots\\__tests__\\__image_snapshots__\\percy.test.js' - 0 matches
**[percy] stopping percy...
[percy] waiting for 0 snapshots to complete...**
[percy] done.
[percy] finalized build #3: https://percy.io/<>
**npm ERR! code ELIFECYCLE
npm ERR! errno 1**
npm ERR! pptr-visual@1.0.0 test:percy: `percy exec -- jest -i './tests-snapshots/__tests__/__image_snapshots__/percy.test.js'`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pptr-visual@1.0.0 test:percy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\<>\AppData\Roaming\npm-cache\_logs\2021-05-13T20_45_52_603Z-debug.log
4

0 回答 0