logdna / logdna/stdlib-node

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

Open
#99 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2
Forks
7
PR merge metrics
No merged PRs in 30d

Description

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/stdlib@1.2.0
├── @playwright/test@1.32.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the fail.js reproduction and inspect the implementation behind stdlib.object.filter, focusing on why its result differs from a normal object during strict equality checks. Done means the filtered result passes the shown toStrictEqual assertion against the equivalent POJO without changing the reported field values.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.