{"id":13407,"library":"jstest","title":"jstest","description":"jstest is an abandoned cross-platform JavaScript test framework, with its last known update around 2014 and the latest npm package version `1.0.5` published in March 2014. It predates most modern JavaScript testing paradigms and tooling, relying heavily on a global `JS.Test` object after a CommonJS `require()`. Unlike contemporary frameworks like Jest or Mocha, jstest offers a very basic set of assertions and test organization (describe/it blocks) without built-in mocking, snapshot testing, or sophisticated test runner features. Its design makes it largely incompatible with modern JavaScript module systems (ESM) and recent Node.js versions. Given its age and lack of maintenance, it is not suitable for new projects and poses significant compatibility and security risks for existing ones.","status":"abandoned","version":"1.0.5","language":"javascript","source_language":"en","source_url":"git://github.com/jcoglan/jstest","tags":["javascript","testing"],"install":[{"cmd":"npm install jstest","lang":"bash","label":"npm"},{"cmd":"yarn add jstest","lang":"bash","label":"yarn"},{"cmd":"pnpm add jstest","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"jstest is a CommonJS module and exports a global 'JS' object. ESM 'import' syntax will not work.","wrong":"import JS from 'jstest';","symbol":"JS","correct":"const JS = require('jstest');"},{"note":"The main testing functions like 'describe', 'it', and 'assert' are nested under the global 'JS.Test' object, not directly exported as named properties from the package root.","wrong":"const { describe } = require('jstest');","symbol":"JS.Test.describe","correct":"const JS = require('jstest');\nJS.Test.describe('My test suite', function() { /* ... */ });"},{"note":"Calling `JS.Test.autorun()` triggers the execution of all defined test suites, typically at the end of your test file. It's not a standalone function but part of the global `JS.Test` object.","wrong":"jstest.autorun();","symbol":"JS.Test.autorun","correct":"const JS = require('jstest');\n// ... define tests ...\nJS.Test.autorun();"}],"quickstart":{"code":"const JS = require('jstest');\n\nJS.Test.describe('My Feature', function() {\n  with (this) {\n    before(function() {\n      this.counter = 0;\n    });\n\n    it('should increment the counter', function() {\n      with (this) {\n        this.counter++;\n        assert(this.counter === 1, 'Counter should be 1');\n      }\n    });\n\n    describe('Nested tests', function() {\n      with (this) {\n        it('should double the counter', function() {\n          with (this) {\n            this.counter *= 2;\n            assert(this.counter === 2, 'Counter should be 2');\n          }\n        });\n      }\n    });\n\n    it('should reset the counter for each top-level test', function() {\n      with (this) {\n        assert(this.counter === 0, 'Counter should be 0 at start of new top-level test');\n      }\n    });\n  }\n});\n\n// Run all defined tests\nJS.Test.autorun();","lang":"javascript","description":"This quickstart demonstrates a basic test suite using `JS.Test.describe`, `it`, and `assert` functions, showcasing the `with(this)` context and `before` hook typical of jstest. It runs all tests using `JS.Test.autorun()`."},"warnings":[{"fix":"Migrate to a actively maintained JavaScript testing framework such as Jest, Mocha, or Vitest.","message":"jstest is an abandoned project, with its last npm publication over a decade ago (March 2014). It receives no maintenance, security updates, or compatibility fixes, making it unsuitable for modern development and potentially vulnerable.","severity":"breaking","affected_versions":">=1.0.5"},{"fix":"Ensure you are using CommonJS `require()` syntax: `const JS = require('jstest');`.","message":"jstest uses CommonJS modules and cannot be directly imported using ES module (ESM) syntax (e.g., `import JS from 'jstest';`). Attempting to do so in an ESM environment will result in a module resolution error.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always capture the module export: `const JS = require('jstest');` and then use `JS.Test.describe`, `JS.Test.it`, etc. In a browser, ensure `jstest.js` is loaded via a `<script>` tag before your test code.","message":"The framework relies on a global `JS.Test` object. If running in a browser environment without proper script tag loading or in a Node.js environment without assigning the `require('jstest')` result to a variable, core functions like `describe` or `it` will be undefined.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If migrating is not an option, you will need to implement more complex assertions manually or integrate a separate, lightweight assertion library (which may introduce its own compatibility challenges).","message":"jstest's assertion API (e.g., `assert(condition, message)`) is significantly less expressive and feature-rich compared to modern `expect()`-based APIs. It lacks matchers for complex comparisons, mocking capabilities, or snapshot testing.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"While `jstest` itself uses it, avoid this pattern in new JavaScript code. If you must use jstest, be aware of the implications. Migration is strongly recommended.","message":"The `with(this)` construct used extensively in jstest for context scoping is a deprecated and discouraged JavaScript feature due to its negative impact on performance and readability, and its potential for unexpected behavior.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Use CommonJS `require()` syntax: `const JS = require('jstest');`.","cause":"Attempting to use ES module `import` syntax with jstest in a Node.js environment configured for CommonJS, or generally in an older Node.js version.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Ensure `const JS = require('jstest');` is at the top of your test file.","cause":"The `jstest` module was not correctly `require()`d or its export was not assigned to a `JS` variable, and subsequently, `JS.Test` is accessed.","error":"ReferenceError: JS is not defined"},{"fix":"Access the testing utilities through the `JS.Test` object: `JS.Test.describe()`, `JS.Test.it()`, etc.","cause":"The `jstest` module was loaded, but `describe` or other test functions are being accessed directly from `JS` instead of `JS.Test`.","error":"TypeError: JS.Test.describe is not a function"},{"fix":"Ensure `assert` is called within the correct context. Inside `it` or `describe` blocks, use `with(this) { assert(...) }` or explicitly `this.assert(...)`.","cause":"The `assert` function is used directly without being bound to the test context, especially outside of a `with(this)` block or without explicit `this.assert`.","error":"TypeError: assert is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null}