Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ubuntu invalid json test failing #289

Closed
philsturgeon opened this issue Nov 7, 2022 · 2 comments
Closed

ubuntu invalid json test failing #289

philsturgeon opened this issue Nov 7, 2022 · 2 comments

Comments

@philsturgeon
Copy link
Member

Release is blocked by this failing test on ubuntu.

   1) Invalid syntax
       in main file
         when continueOnError is true
           should throw a grouped error for an invalid JSON file with YAML disabled:

      AssertionError: expected [ Array(1) ] to contain subset [ Array(1) ]
      + expected - actual

       [
      -  "ParserError: Error parsing /home/runner/work/json-schema-ref-parser/json-schema-ref-parser/test/specs/invalid/invalid.json: Expected property name or '}' in JSON at position 2"
      +  {
      +    "message": [Function]
      +    "name": "ParserError"
      +    "path": []
      +    "source": [Function]
      +  }
       ]
      
      at Context.<anonymous> (test/specs/invalid/invalid.spec.js:159:33)

This test looks like its expecting a particular error object format for expect(err.errors).to.containSubset([ which is simply not there on ubuntu.

it("should throw a grouped error for an invalid JSON file with YAML disabled", async () => {
        const parser = new $RefParser();
        try {
          await parser.dereference(path.rel("specs/invalid/invalid.json"), { continueOnError: true, parse: { yaml: false }});
          helper.shouldNotGetCalled();
        }
        catch (err) {
          expect(err).to.be.instanceof(JSONParserErrorGroup);
          expect(err.files).to.equal(parser);
          expect(err.message).to.equal(`1 error occurred while reading '${path.abs("specs/invalid/invalid.json")}'`);
          expect(err.errors.length).to.equal(1);
          expect(err.errors).to.containSubset([
            {
              name: ParserError.name,
              message: message => (
                message.includes("invalid.json: Unexpected end of JSON input") ||
                message.includes("invalid.json: JSON.parse: end of data while reading object contents") ||    // Firefox
                message.includes("invalid.json: JSON Parse error: Expected '}'") ||                           // Safari
                message.includes("invalid.json: JSON.parse Error: Invalid character") ||                      // Edge
                message.includes("invalid.json: Syntax error")                                                // IE
              ),
              path: [],
              source: message => message.endsWith("test/specs/invalid/invalid.json"),
            }
          ]);
        }
      });
@danielfcollier
Copy link
Contributor

danielfcollier commented Nov 13, 2022

From the Windows issue, I've seen that sometimes error messages might change after OS updates. @philsturgeon, what is the CI-CD workflow action that you are referring to?

Get a URL from https://github.com/APIDevTools/json-schema-ref-parser/actions

example: https://github.com/APIDevTools/json-schema-ref-parser/actions/runs/3411685713

@philsturgeon
Copy link
Member Author

@jonluca jonluca closed this as completed Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants