
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
@achingbrain/chai-string
Advanced tools
Fork of chai-string
chai.string.XXX
, only supports expect
/assert
style assertionsMatchers for chai to help with common string comparison assertions.
<script src="chai.js"></script>
<script src="chai-string.js"></script>
import * as chai from 'chai'
import string from '@achingbrain/chai-string'
chai.use(require('chai-string'))
All assertions are defined for both the BDD and TDD syntax but some aliases exist to make the assertions look good with both styles.
var d1 = 'abcdef',
d2 = 'abc';
d1.should.startWith.d2
expect(d1).to.startsWith(d2)
assert.startsWith(d1, d2)
assert.startsWith('abcdef', 'abc');
expect('abcdef').to.startsWith('abc');
'abcdef'.should.startWith('abc');
assert.endsWith('abcdef', 'def');
expect('abcdef').to.endsWith('def');
'abcdef'.should.endWith('def');
assert.equalIgnoreCase('abcdef', 'AbCdEf');
expect('abcdef').to.equalIgnoreCase('AbCdEf');
assert.equalIgnoreSpaces('abcdef', 'a\nb\tc\r d ef');
expect('abcdef').to.equalIgnoreSpaces('a\nb\tc\r d ef');
assert.containIgnoreSpaces('abcdefgh', 'a\nb\tc\r d ef');
expect('abcdefgh').to.containIgnoreSpaces('a\nb\tc\r d ef');
assert.containIgnoreCase('abcdefgh', 'AbcDefGH');
expect('abcdefgh').to.containIgnoreCase('AbcDefGH');
'abcdef'.should.containIgnoreCase('cDe');
assert.singleLine('abcdef');
expect('abcdef').to.be.singleLine();
assert.reverseOf('abcdef', 'fedcba');
expect('abcdef').to.be.reverseOf('fedcba');
assert.palindrome('abccba');
expect('abccba').to.be.palindrome();
assert.entriesCount('abcabd', 'ab', 2);
expect('abcabd').to.have.entriesCount('ab', 2);
assert.indexOf('abcabd', 'ab', 0);
expect('abcabd').to.have.indexOf('ab', 0);
Thanks to the chai-datetime module for giving me an idea for how to structure and test a chai plugin.
FAQs
strings comparison matchers for chai
The npm package @achingbrain/chai-string receives a total of 366 weekly downloads. As such, @achingbrain/chai-string popularity was classified as not popular.
We found that @achingbrain/chai-string demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.