Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

object.filter'd objects fail strictEquals checks with normal object

未关闭
#99 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript
领域
tooling

调研方向

运行 fail.js 复现并检查 stdlib.object.filter 背后的实现,重点关注为什么它的结果在严格相等检查中不同于普通对象。完成的标准是:过滤后的结果在不更改所报告字段值的情况下,通过针对等效 POJO 的所示 toStrictEqual 断言。

由索引模型根据 Issue 内容生成。

描述

If you filter an object, and try to strictEqual it with a POJO with the filtered fields, the assertion fails.

import {expect} from '@playwright/test'
import stdlib  from '@logdna/stdlib'

const o = {
    field: 'val'
    , field2: 'val2'
}

const e = {field: 'val'}
const f = stdlib.object.filter(o, (k) => k !== 'field2')

console.log(e)
console.log(f)

expect(e).toStrictEqual(f)

I'm not sure where playwright gets it's expect library from, and couldn't find out with a few minutes of searching.

> node fail.js
{ field: 'val' }
[Object: null prototype] { field: 'val' }
/Users/jmoses/dev/logdna/qa-e2e-pipeline/node_modules/@playwright/test/lib/matchers/expect.js:131
      if (!testInfo) return matcher.call(target, ...args);
                                    ^

Ze [Error]: expect(received).toStrictEqual(expected) // deep equality

Expected: {"field": "val"}
Received: serializes to the same string
    at Proxy.<anonymous> (/Users/jmoses/dev/logdna/qa-e2e-pipeline/node_modules/@playwright/test/lib/matchers/expect.js:131:37)
    at file:///Users/jmoses/dev/logdna/qa-e2e-pipeline/fail.js:15:11
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at loadESM (node:internal/process/esm_loader:88:5)
    at handleMainPromise (node:internal/modules/run_main:61:12) {
  matcherResult: {
    actual: { field: 'val' },
    expected: [Object: null prototype] { field: 'val' },
    message: '\x1B[2mexpect(\x1B[22m\x1B[31mreceived\x1B[39m\x1B[2m).\x1B[22mtoStrictEqual\x1B[2m(\x1B[22m\x1B[32mexpected\x1B[39m\x1B[2m) // deep equality\x1B[22m\n' +
      '\n' +
      'Expected: \x1B[32m{"field": "val"}\x1B[39m\n' +
      'Received: serializes to the same string',
    name: 'toStrictEqual',
    pass: false
  }
}
> npm list | grep -E 'playwright/test|logdna/stdlib'
├── @logdna/[email protected]
├── @playwright/[email protected]
主要语言
JavaScript
星标
2
派生
7
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。