npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@open-wxa/wxa-runner-playwright

v0.13.1

Published

Playwright fixture for wxa-runner: starts the dev server per worker, reads page data and asserts mini-program requests

Readme

@open-wxa/wxa-runner-playwright

在 Playwright 里测试微信小程序:每个 worker 自动启动 wxa-runner 开发服务器, 用例里直接拿到 miniProgram,能读页面 data、断言小程序发出的请求,跳转后不用手动等待。

pnpm add -D @playwright/test @open-wxa/wxa-runner-playwright
// playwright.config.ts,放在小程序项目目录(project.config.json 所在目录)
import { defineConfig } from '@playwright/test';
import type { WxaOptions } from '@open-wxa/wxa-runner-playwright';

export default defineConfig<WxaOptions>({
  testDir: 'e2e',
  use: { channel: 'chrome' }
});
// e2e/order.spec.ts
import { test, expect } from '@open-wxa/wxa-runner-playwright';

test('提交订单后跳转到结果页', async ({ miniProgram }) => {
  await miniProgram.mock('login', { code: 'test_code' });   // 打开前声明,App.onLaunch 里就生效
  await miniProgram.route('POST **/api/orders', { status: 201, body: { id: 'o-1' } });
  await miniProgram.open('pages/cart/cart');

  await miniProgram.current.locator('#submit').click();

  await expect(miniProgram).toHavePath('pages/result/result');
  await expect(miniProgram).toHavePageData({ orderId: 'o-1' });
  expect((await miniProgram.waitForRequest('POST **/api/orders')).body).toEqual({ skuId: 1, count: 2 });
});
  • miniProgram 的每个成员都有类型注释,编辑器里悬停就能看到说明
  • mock、route 可以传 Node 里的函数,能用用例里的变量、检查参数;函数抛错时用例失败
  • 用例结束时检查运行时错误和未实现的 wx API,wxaCheckErrors: false 可以关掉
  • 每个 worker 一个开发服务器,每个用例一个新的浏览器上下文,并行运行互不影响
  • web-view 的网页和小程序不同域名时,test.use({ wxaWebView: 'window' }) 让网页在新窗口打开,Cookie 才能正常使用,miniProgram.webView() 拿到这个窗口
  • Chrome 默认带上 --js-flags=--no-enable-lazy-source-positions,Playwright 连着浏览器时基础库初始化不用重新解析源码,打开页面快约 1/3

配置项、mock 的限制等见 在 Playwright 中测试。

不用 fixture

只用 Playwright 自带的 webServer 也能测试(先装上命令行:pnpm add -D wxa-runner),在用例里通过 window.__wxa_test_api__ 操作:

// playwright.config.ts
import { defineConfig } from '@playwright/test';

export default defineConfig({
  webServer: {
    command: 'npx wxa-runner dev . --no-watch --port 3000',
    url: 'http://localhost:3000',
    reuseExistingServer: !process.env.CI
  },
  use: { baseURL: 'http://localhost:3000', channel: 'chrome' }
});

写法见 测试 API。