
Security News
PyPI Expands Trusted Publishing to GitLab Self-Managed as Adoption Passes 25 Percent
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads
The
assertmodule from Node.js, for the browser.
With browserify, simply require('assert') or use the assert global and you will get this module.
The goal is to provide an API that is as functionally identical to the Node.js assert API as possible. Read the official docs for API documentation.
To use this module directly (without browserify), install it as a dependency:
npm install assert
assertDue to differences between browsers, some error properties such as message and stack will be inconsistent. However the assertion behaviour is as close as possible to Node.js and the same error code will always be used.
Bundlers like webpack 5 and Vite.js (and possibly others) don't automatically include polyfills for Node.js APIs. Like most packages on npm, this module depends on other Node.js APIs, so it won't work with these bundlers without also including a polyfill for the process Node.js global. You can use this library to polyfill the process global.
Note that this is not a flaw in this package - this package will work without any manual configuration with browserify and webpack 4 and other working bundlers. Unfortunately, some bundlers decided to require an explicit allow-list of all Node.js API specific packages instead of having them work out of the box, hence the incompatibility. See https://github.com/browserify/commonjs-assert/issues/55 for some more context.
To contribute, work on the source files. Then build and run the tests against the built files. Be careful to not introduce syntax that will be transpiled down to unsupported syntax. For example, for...of loops will be transpiled to use Symbol.iterator which is unavailable in IE.
npm run buildBuilds the project into the build dir.
npm run devWatches source files for changes and rebuilds them into the build dir.
npm run testBuilds the source files into the build dir and then runs the tests against the built project.
npm run test:nobuildRuns the tests against the built project without rebuilding first.
This is useful if you're debugging in the transpiled code and want to re-run the tests without overwriting any changes you may have made.
npm run test:sourceRuns the tests against the unbuilt source files.
This will only work on modern Node.js versions.
npm run test:browsersRun browser tests against the all targets in the cloud.
Requires airtap credentials to be configured on your machine.
npm run test:browsers:localRun a local browser test server. No airtap configuration required.
When paired with npm run dev any changes you make to the source files will be automatically transpiled and served on the next request to the test server.
MIT © Joyent, Inc. and other Node contributors
2.1.0
assert.match() and assert.doesNotMatch()is-nan, object-is, util@babel/cli, @babel/core, @babel/preset-env, airtap, core-js, cross-eng, object.entries, object.getownpropertydescriptors, tapeChai is a BDD/TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework. It offers more plugins and a more flexible API compared to assert.
Expect is a minimalistic assertion library that provides a set of assertion functions and is often used with Jest. It offers a more fluent and readable syntax compared to assert.
Should.js is an expressive, readable, framework-agnostic assertion library. It extends the Object prototype with a single non-enumerable getter that allows for a more fluent and chainable API, providing a different style of coding compared to assert.
FAQs
The assert module from Node.js, for the browser.
The npm package assert receives a total of 11,434,651 weekly downloads. As such, assert popularity was classified as popular.
We found that assert demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.