@cerios/playwright-expectly-core

中文文档
1.1.1发布于 2026/11/06MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 2627

Shared utilities for @cerios/playwright-expectly packages.

原始使用文档
文档目录4 节
  1. What's inside
  2. Usage (for @cerios/playwright-expectly* package authors)
  3. Links
  4. License

@cerios/playwright-expectly-core

npm version License: MIT

Shared internal utilities used by the @cerios/playwright-expectly and @cerios/playwright-expectly-fuzzy packages.

This package is not meant to be installed or used directly. It's a dependency of the other @cerios/playwright-expectly* packages and exists to avoid duplicating shared matcher-building logic between them. Its API may change without following semver as strictly as the consumer-facing packages.

What's inside

  • withMatcherState(matchers) — wraps a plain matcher-function object so each matcher has typed access to Playwright's matcher state (this.isNot, this.utils, etc.) inside expect.extend()-style definitions, and keeps error stacks pointing at the user's call site.
  • runPolledMatcher(state, options, poll, { target, until, waitFullTimeout }) — shared polling loop with the timing of Playwright's expect.poll(), without the nested report steps expect.poll() would add. When the target page or context closes (as it does when the test times out), polling stops at once and the matcher's failure message gets a note saying so, so the matcher still reports the last value it saw. With waitFullTimeout, polling waits out the time left after the last read instead of giving up when the next interval would cross the deadline.
  • pollLocators(...), locatorNotFoundMessage(...), hasElements(locator), assertLocators(...) — locator polling with Playwright's semantics for missing elements, and the shared "element(s) not found" failure message.
  • PollOptions, PolledMatcherOptions, Closeable, MatcherReturnType — shared TypeScript types for polling matchers.

Usage (for @cerios/playwright-expectly* package authors)

import { withMatcherState } from "@cerios/playwright-expectly-core";

export const myMatchers = withMatcherState({
    toBeSomething(actual: unknown) {
        // `this` here is typed with Playwright's ExpectMatcherState
        return { pass: actual === "something", message: () => "..." };
    },
});

License

MIT © Cerios

版本与发布记录

@cerios/playwright-expectly-core 共发布 7 个版本,首次发布于 2026/06/13;过去 12 个月发布了 7 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.1.1latest2026/11/063 天前
1.1.02026/10/2613 天前
1.0.12026/09/161 个月前
1.0.02026/07/163 个月前
0.1.12026/07/034 个月前
0.1.02026/06/134 个月前

关于 @cerios/playwright-expectly-core 的常见问题

@cerios/playwright-expectly-core 是什么?

Shared utilities for @cerios/playwright-expectly packages.

如何安装 @cerios/playwright-expectly-core?

在项目目录运行 npm install @cerios/playwright-expectly-core,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@playwright/test(>=1.40.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cerios/playwright-expectly-core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cerios/playwright-expectly-core 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@cerios/playwright-expectly-core 可以商用吗?

@cerios/playwright-expectly-core 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cerios/playwright-expectly-core 的下载量有多少?

根据 npm 官方下载统计,@cerios/playwright-expectly-core 在 2026/10/10 – 2026/11/08 这 30 天内被下载 2,627 次,日均约 88 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cerios/playwright-expectly-core 还在维护吗?

最新版本 1.1.1 发布于 2026/11/06(3 天前);至今共发布 7 个版本,其中过去 12 个月发布了 7 个;首次发布于 2026/06/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。