{"id":13716102,"url":"https://github.com/node-modules/should2assert","last_synced_at":"2025-05-07T05:32:11.219Z","repository":{"id":47134824,"uuid":"85970100","full_name":"node-modules/should2assert","owner":"node-modules","description":"A tool to help you migrating from should to assert","archived":true,"fork":false,"pushed_at":"2024-07-03T00:24:16.000Z","size":44,"stargazers_count":13,"open_issues_count":8,"forks_count":3,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-11T21:49:12.473Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/node-modules.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-23T16:07:01.000Z","updated_at":"2024-07-03T02:33:51.000Z","dependencies_parsed_at":"2024-05-23T02:38:27.284Z","dependency_job_id":"833fd4e9-3a83-471c-9e6d-7547a4738b82","html_url":"https://github.com/node-modules/should2assert","commit_stats":{"total_commits":10,"total_committers":3,"mean_commits":"3.3333333333333335","dds":0.4,"last_synced_commit":"68faeef9941641e5fc0cebf0cf9cc089648d2ad6"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fshould2assert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fshould2assert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fshould2assert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fshould2assert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/node-modules","download_url":"https://codeload.github.com/node-modules/should2assert/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252823139,"owners_count":21809700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T00:01:07.068Z","updated_at":"2025-05-07T05:32:10.602Z","avatar_url":"https://github.com/node-modules.png","language":"JavaScript","readme":"# should2assert\nA tool to help you migrating from should to assert\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/should2assert.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/should2assert\n[travis-image]: https://img.shields.io/travis/node-modules/should2assert.svg?style=flat-square\n[travis-url]: https://travis-ci.org/node-modules/should2assert\n[codecov-image]: https://codecov.io/gh/node-modules/should2assert/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/node-modules/should2assert\n[david-image]: https://img.shields.io/david/node-modules/should2assert.svg?style=flat-square\n[david-url]: https://david-dm.org/node-modules/should2assert\n[snyk-image]: https://snyk.io/test/npm/should2assert/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/should2assert\n[download-image]: https://img.shields.io/npm/dm/should2assert.svg?style=flat-square\n[download-url]: https://npmjs.org/package/should2assert\n\n## Install\n\n```bash\n$ npm install should2assert -g\n```\n\nNode.js \u003e= 6.0.0 required\n\n## Usage\n\n```\nUsage\n  $ should2assert [\u003cfile|glob\u003e ...]\n\nOptions\n  -c, --cwd  current working directory\n\nExamples\n  $ should2assert test\n```\n\n## Example\n\n**input file**\n```js\n'use strict';\n\nconst mm = require('mm');\nconst should = require('should');\n\ndescribe('test/xxx.test.js', () =\u003e {\n  beforeEach(mm.restore);\n\n  it('should be ok', () =\u003e {\n    const a = '123';\n    const b = 123;\n    const c = false;\n    a.should.eql('123');\n    b.should.eql(123);\n    const obj = { a, b, c };\n    obj.should.eql({ a, b, c });\n    obj.a.should.eql(a);\n    a.should.not.eql('321');\n    obj.a.should.not.eql(b);\n    a.should.be.ok();\n    c.should.not.be.ok();\n    obj.b.should.be.ok();\n    obj.c.should.not.be.ok();\n    should.exist(a);\n    should.exist(obj.a);\n    should.not.exist(c);\n    should.not.exist(obj.c);\n    (function() {\n      throw new Error('fail');\n    }).should.throw('fail');\n    (() =\u003e {\n      throw new Error('mock error');\n    }).should.throw(/mock error/);\n    (() =\u003e {\n      throw new Error('mock error');\n    }).should.throw();\n    obj.should.have.properties('a');\n    obj.should.have.properties([ 'a', 'b' ]);\n    obj.should.have.properties({ a: '123', c: false });\n\n    const offset = 1;\n    const zero = 0;\n    const str = '';\n    const obj = {};\n    const arr = [];\n    const b = true;\n    const fn = () =\u003e {};\n    const err = new Error('mock error');\n    const date = new Date();\n    assert(offset);\n    offset.should.be.ok;\n    offset.should.be.ok();\n    zero.should.not.be.ok;\n    zero.should.not.be.ok();\n    zero.should.be.not.ok;\n    zero.should.be.not.ok();\n    offset.should.be.a.Number;\n    offset.should.be.a.Number();\n    str.should.be.a.String;\n    str.should.be.a.String();\n    obj.should.be.an.Object;\n    obj.should.be.an.Object();\n    arr.should.be.an.Array;\n    arr.should.be.an.Array();\n    b.should.be.a.Boolean;\n    b.should.be.a.Boolean();\n    fn.should.be.a.Function;\n    fn.should.be.a.Function();\n    err.should.be.an.Error;\n    err.should.be.an.Error();\n    ('123').should.not.be.a.Number;\n    ('123').should.not.be.a.Number();\n    (123).should.not.be.a.String;\n    (123).should.not.be.a.String();\n    (123).should.not.be.a.Boolean;\n    (123).should.not.be.a.Boolean();\n    (123).should.not.be.a.Function;\n    (123).should.not.be.a.Function();\n    (123).should.not.be.a.Object;\n    (123).should.not.be.a.Object();\n    (123).should.not.be.an.Array;\n    (123).should.not.be.an.Array();\n    (123).should.not.be.an.Error;\n    (123).should.not.be.an.Error();\n    (123).should.not.be.Array;\n    (123).should.not.be.Error;\n    obj.should.not.be.Error;\n    obj.should.be.an.instanceof(Object);\n    (123).should.be.an.instanceof(Number);\n    (123).should.not.be.an.instanceof(Object);\n    obj.should.not.be.an.instanceof(Number);\n    date.should.be.a.Date;\n    date.should.be.a.Date();\n    obj.should.not.be.a.Date;\n    obj.should.not.be.a.Date();\n  });\n});\n```\n\n**output file**\n```js\n'use strict';\n\nconst assert = require('assert');\nconst mm = require('mm');\n\ndescribe('test/xxx.test.js', () =\u003e {\n  beforeEach(mm.restore);\n\n  it('should be ok', () =\u003e {\n    const a = '123';\n    const b = 123;\n    const c = false;\n    assert(a === '123');\n    assert(b === 123);\n    const obj = { a, b, c };\n    assert.deepEqual(obj, { a, b, c });\n    assert.deepEqual(obj.a, a);\n    assert(a !== '321');\n    assert.notStrictEqual(obj.a, b);\n    assert(a);\n    assert(!c);\n    assert(obj.b);\n    assert(!obj.c);\n    assert(a);\n    assert(obj.a);\n    assert(!c);\n    assert(!obj.c);\n    assert.throws(function() {\n      throw new Error('fail');\n    }, 'fail');\n    assert.throws(() =\u003e {\n      throw new Error('mock error');\n    }, /mock error/);\n    assert.throws(() =\u003e {\n      throw new Error('mock error');\n    });\n    assert(['a'].every(p =\u003e Object.prototype.hasOwnProperty.call(obj, p)));\n    assert(['a', 'b'].every(p =\u003e Object.prototype.hasOwnProperty.call(obj, p)));\n    Object.keys({ a: '123', c: false }).forEach(p =\u003e assert.deepEqual((obj)[p], ({ a: '123', c: false })[p]));\n\n    const offset = 1;\n    const zero = 0;\n    const str = '';\n    const obj = {};\n    const arr = [];\n    const b = true;\n    const fn = () =\u003e {};\n    const err = new Error('mock error');\n    const date = new Date();\n    assert(offset);\n    assert(offset);\n    assert(offset);\n    assert(!zero);\n    assert(!zero);\n    assert(!zero);\n    assert(!zero);\n    assert(typeof offset === 'number');\n    assert(typeof offset === 'number');\n    assert(typeof str === 'string');\n    assert(typeof str === 'string');\n    assert(typeof obj === 'object');\n    assert(typeof obj === 'object');\n    assert(Array.isArray(arr));\n    assert(Array.isArray(arr));\n    assert(typeof b === 'boolean');\n    assert(typeof b === 'boolean');\n    assert(typeof fn === 'function');\n    assert(typeof fn === 'function');\n    assert(err instanceof Error);\n    assert(err instanceof Error);\n    assert(typeof '123' !== 'number');\n    assert(typeof '123' !== 'number');\n    assert(typeof 123 !== 'string');\n    assert(typeof 123 !== 'string');\n    assert(typeof 123 !== 'boolean');\n    assert(typeof 123 !== 'boolean');\n    assert(typeof 123 !== 'function');\n    assert(typeof 123 !== 'function');\n    assert(typeof 123 !== 'object');\n    assert(typeof 123 !== 'object');\n    assert(!Array.isArray(123));\n    assert(!Array.isArray(123));\n    assert(!(123 instanceof Error));\n    assert(!(123 instanceof Error));\n    assert(!Array.isArray(123));\n    assert(!(123 instanceof Error));\n    assert(!(obj instanceof Error));\n    assert(obj instanceof Object);\n    assert(123 instanceof Number);\n    assert(!(123 instanceof Object));\n    assert(!(obj instanceof Number));\n    assert(Object.prototype.toString.call(date) === '[object Date]');\n    assert(Object.prototype.toString.call(date) === '[object Date]');\n    assert(Object.prototype.toString.call(obj) !== '[object Date]');\n    assert(Object.prototype.toString.call(obj) !== '[object Date]');\n  });\n});\n```","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-modules%2Fshould2assert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnode-modules%2Fshould2assert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-modules%2Fshould2assert/lists"}