Skip to content

JSON.parse(patterns) done on an object and not on a string #7

@oddball

Description

@oddball

Just tried to use this package, but ran into a problem.

I tried

const Swift = require("swift-mock");
const swift = new Swift();

But it fails with something like

SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
    at new Swift (/whatever/node_modules/swift-mock/lib/swift.js:19:33)

I had a look in the code. At

this.fieldPatterns = JSON.parse(patterns);

JSON.parse is done on patterns. But patterns already is an object and it fails.

Same thing at

this.fieldPatterns = fieldPatterns ? JSON.parse(fieldPatterns) : patterns;

After I changed that I could parse my Swift file. I am sitting on

npx node --version
v10.15.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions