{"id":27087,"library":"jsonscript-test","title":"jsonscript-test","description":"jsonscript-test (v0.6.0) is a testing library for JSONScript scripts, allowing developers to define and run test suites that validate script behavior. It is part of the JSONScript ecosystem and is currently a work in progress, with an unstable API expected to evolve. Unlike general testing frameworks, it is tailored specifically for JSONScript's declarative execution model. Release cadence is sporadic, as the project is in early development.","status":"active","version":"0.6.0","language":"javascript","source_language":"en","source_url":"https://github.com/JSONScript/jsonscript-test","tags":["javascript","JSONScript","testing"],"install":[{"cmd":"npm install jsonscript-test","lang":"bash","label":"npm"},{"cmd":"yarn add jsonscript-test","lang":"bash","label":"yarn"},{"cmd":"pnpm add jsonscript-test","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only since v0.6.0; CommonJS require() will fail.","wrong":"const test = require('jsonscript-test')","symbol":"default","correct":"import test from 'jsonscript-test'"},{"note":"Named export for running a test suite; CommonJS not supported.","wrong":"const { runSuite } = require('jsonscript-test')","symbol":"runSuite","correct":"import { runSuite } from 'jsonscript-test'"},{"note":"Subpath imports are not defined; incorrect path may cause resolution errors.","wrong":"import { defineSuite } from 'jsonscript-test/test'","symbol":"defineSuite","correct":"import { defineSuite } from 'jsonscript-test'"}],"quickstart":{"code":"import test, { runSuite, defineSuite } from 'jsonscript-test';\n\n// Define a test suite\nconst suite = defineSuite({\n  name: 'My Suite',\n  tests: [\n    {\n      name: 'addition',\n      script: { $op: 'add', left: 1, right: 2 },\n      expected: 3\n    }\n  ]\n});\n\n// Run the suite\nconst results = runSuite(suite);\nconsole.log(results); // outputs test results","lang":"typescript","description":"Demonstrates defining and running a test suite for a JSONScript script, with import examples."},"warnings":[{"fix":"Pin to exact version and expect breaking changes.","message":"Package is a work in progress; API is unstable and may change without notice.","severity":"gotcha","affected_versions":"*"},{"fix":"Use ES module imports or downgrade to v0.5.x if CJS needed.","message":"v0.6.0 switched to ESM-only; CommonJS require() will throw an error.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Validate JSONScript scripts before including in test suites.","message":"Test suites must follow JSONScript schema; invalid scripts cause silent failures.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Add \"type\": \"module\" to package.json or use .mjs extension.","cause":"Running ESM code in a non-module Node.js environment.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Switch to import statements or downgrade to v0.5.0.","cause":"Using require() in an ESM context after v0.6.0.","error":"TypeError: require is not a function"},{"fix":"Ensure JSONScript script produces correct output; check script definition.","cause":"Test script returned undefined instead of expected value.","error":"AssertionError: expected undefined to deeply equal 3"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}