Skip to content

Commit

Permalink
fix: tests for new Node.js parsers, unify jest configs (#7)
Browse files Browse the repository at this point in the history
* fix: tests for new Node.js parsers, unify jest configs

* chore: require dune 3.9
  • Loading branch information
anmonteiro authored Feb 3, 2024
1 parent 2a026e6 commit 5f884a5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(lang dune 3.8)
(lang dune 3.9)

(using melange 0.1)

Expand Down
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
rootDir: "./_build/default/",
testMatch: ["**/*_test.js"],
rootDir : "./_build/default/",
testMatch : [ "**/*_test.js" ],
testEnvironment : "node"
};

2 changes: 1 addition & 1 deletion melange-json.opam
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ license: ["LGPL-3.0-only" "MPL-2.0"]
homepage: "https://github.com/melange-community/melange-json/"
bug-reports: "https://github.com/melange-community/melange-json/issues"
depends: [
"dune" {>= "3.8"}
"dune" {>= "3.9"}
"ocaml" {>= "5.1"}
"melange" {>= "3.0.0"}
"melange-jest" {with-test}
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"devDependencies": {
"jest": "^26.5.2"
},
"jest": {
"testEnvironment": "node"
}
}
11 changes: 10 additions & 1 deletion src/__tests__/Json_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ let _ =
try
let (_ : Js.Json.t) = parseOrRaise "{" in
fail "should throw"
with ParseError "Unexpected end of JSON input" -> pass));
with
| ParseError "Unexpected end of JSON input"
| ParseError (* Node.js v20 *)
"Expected property name or '}' in JSON at position 1"
| ParseError
(* Node.js v21 *)
"Expected property name or '}' in JSON at position 1 (line 1 \
column 2)"
->
pass));

test "stringify" (fun () -> expect @@ stringify Encode.null |> toEqual "null")

0 comments on commit 5f884a5

Please sign in to comment.