Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ns16/tap-plugin-matchjsonschema
TAP plugin for JSON schema
https://github.com/ns16/tap-plugin-matchjsonschema
assert assertion json json-schema tap tap-plugin tapjs tapjs-plugin test testing
Last synced: 18 days ago
JSON representation
TAP plugin for JSON schema
- Host: GitHub
- URL: https://github.com/ns16/tap-plugin-matchjsonschema
- Owner: ns16
- License: other
- Created: 2024-01-09T13:47:49.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2024-02-25T10:52:36.000Z (11 months ago)
- Last Synced: 2024-11-14T16:11:57.449Z (about 2 months ago)
- Topics: assert, assertion, json, json-schema, tap, tap-plugin, tapjs, tapjs-plugin, test, testing
- Language: TypeScript
- Homepage:
- Size: 80.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# `tap-plugin-matchjsonschema`
Plugin for the [TAP](https://node-tap.org/) test framework. This plugin verify if the value matches the provided JSON schema.
To install the plugin, run the following command:
```
npx tap plugin add tap-plugin-matchjsonschema
```Usage example:
```
import t from 'tap'const schema = {
type: 'object',
required: ['id', 'name', 'username', 'email', 'createdAt', 'updatedAt'],
properties: {
id: { type: 'number', minimum: 1 },
name: { type: 'string', maxLength: 100 },
username: { type: 'string', maxLength: 100 },
email: { type: 'string', maxLength: 100, format: 'email' },
createdAt: { type: 'string', format: 'date-time' },
updatedAt: { type: 'string', format: 'date-time' }
},
additionalProperties: false
}t.test('success', t => {
const data = {
id: 1,
name: 'Sheldon Bahringer',
username: 'Sheldon52',
email: '[email protected]',
createdAt: '2023-07-01 00:00:00',
updatedAt: '2023-07-01 00:00:00'
}
t.matchJsonSchema(data, schema)
t.end()
})
```