Skip to content

[Bug?]: Constraints plugin does not stringify expected object value #3282

@noahnu

Description

@noahnu

Self-service

  • I'd be willing to implement a fix

Describe the bug

When running the constraints plugin, if the expected field value is an object, it prints [object Object] rather than the JSON stringified (or human readable) form.

To reproduce

const fs = require('fs');

await packageJsonAndInstall({
    bin: {
        key: 'this is visible',
    },
    _bin: {
        key: './bin/entry.js',
    }
});

const constraints = `gen_enforced_field(WorkspaceCwd, 'bin', Value) :- workspace_field(WorkspaceCwd, '_bin', Value).`;
await fs.promises.writeFile('constraints.pro', constraints, 'utf-8');

await expect(yarn(`constraints`)).rejects.toThrow(expect.stringContaining('[object Object]'));

and you'll see:

image

Environment

System:
OS: macOS 11.4
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 14.17.3 - /private/var/folders/ft/b9p2qq2n2h31j10zcc8d48qh0000gp/T/xfs-ad65a9aa/node
Yarn: 3.0.0 - /private/var/folders/ft/b9p2qq2n2h31j10zcc8d48qh0000gp/T/xfs-ad65a9aa/yarn

Additional context

The existing value is printed correctly. It's only the expected value having issues.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingreproducibleThis issue can be successfully reproduced

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions