Socket
Socket
Sign inDemoInstall

node-jasmine-file-contents-matcher

Package Overview
Dependencies
2
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-jasmine-file-contents-matcher

A Jasmine 2 custom matcher that compares a result against the contents of a file.


Version published
Maintainers
1
Install size
147 kB
Created

Readme

Source

node-jasmine-file-contents-matcher

A Jasmine 2 custom matcher that compares a result against the contents of a file.

Build status: Run Status

Test coverage: Coverage Badge

Installation

npm install node-jasmine-file-contents-matcher

Usage

Place the following call before your tests in your suite

require('node-jasmine-file-contents-matcher');

Place your expected result files in a folder resources/expectedresults

Use your matchers according to the examples below

it('should match when the file content is identical to the expected', function (done) {
    expect('a string').toEqualFileContents('file-name', done);
});

it('should match when the file content contains the expected', function (done) {
    expect('a string').toContainFileContents('file-name', done);
});

//You can use the .not modifier

it('should not match when file content is not identical to the expected', function(done) {
    expect('Not going to match').not.toEqualFileContents('file-name', done);
});

it('should not match when the file content doesn`t contain the expected', function (done) {
    expect('Not going to match').not.toContainFileContents('file-name', done);
});

The filenames must be whatever is passed as the first parameter in the matcher call plus the '.txt' extension.

In the example above, the expected result file should be: resources/expectedresults/file-name.txt.

###The following matchers are available

.toEqualFileContents

.toContainFileContents

.toEqualFileContentsIgnoreLineBreaks

.toContainFileContentsIgnoreLineBreaks

Development

If you want to build and test this project you will be able to by:

npm install
npm test

Keywords

FAQs

Last updated on 25 Aug 2016

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc