3.0.3 • Published 27 days ago

@comunica/jest v3.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
27 days ago

Comunica Jest helpers

npm version

Jest test helpers for Comunica

This module is part of the Comunica framework, and should only be used by developers that want to build their own query engine.

Click here if you just want to query with Comunica.

Install

$ yarn add --save-dev @comunica/jest

Configuration

In order to use matchers in your tests, you'll have to make sure that they are imported. This can be done by adding the following entry to your Jest configuration:

{
  "jest": {
    "setupFilesAfterEnv": ["@comunica/jest"]
  }
}

If you are already using an existing test framework script file, make sure to add @comunica/jest as follows to your file:

...
require('@comunica/jest');

Optional: Typescript typings configuration

If you are using TypeScript, possibly in combination with ts-jest, you will need to import the typings of this package to make the TS compiler recognise the new matchers.

For this, include the following import at the top of each applicable test file:

import "@comunica/jest";

API

All examples below make use of these helpers:

import { BindingsFactory } from '@comunica/bindings-factory';
import { DataFactory } from 'rdf-data-factory';

const BF = new BindingsFactory();
const DF = new DataFactory();

toEqualBindings

Check if two Bindings are equal.

expect(BF.bindings([
  [ DF.variable('a'), DF.namedNode('a1') ],
  [ DF.variable('b'), DF.namedNode('b1') ],
])).toEqualBindings(BF.bindings([
  [ DF.variable('a'), DF.namedNode('a1') ],
  [ DF.variable('b'), DF.namedNode('b1') ],
]));

toEqualBindingsArray

Check if two Bindings arrays are equal.

expect([
  BF.bindings([
    [ DF.variable('a'), DF.namedNode('a1') ],
    [ DF.variable('b'), DF.namedNode('b1') ],
  ]),
  BF.bindings([
    [ DF.variable('b'), DF.namedNode('b1') ],
    [ DF.variable('c'), DF.namedNode('c1') ],
  ]),
]).toEqualBindingsArray([
  BF.bindings([
    [ DF.variable('a'), DF.namedNode('a1') ],
    [ DF.variable('b'), DF.namedNode('b1') ],
  ]),
  BF.bindings([
    [ DF.variable('b'), DF.namedNode('b1') ],
    [ DF.variable('c'), DF.namedNode('c1') ],
  ]),
]);

toEqualBindingsStream

Check if a Bindings stream equals a Bindings array.

import { ArrayIterator } from 'asynciterator';

expect(new ArrayIterator([
  BF.bindings([
    [ DF.variable('a'), DF.namedNode('a1') ],
    [ DF.variable('b'), DF.namedNode('b1') ],
  ]),
  BF.bindings([
    [ DF.variable('b'), DF.namedNode('b1') ],
    [ DF.variable('c'), DF.namedNode('c1') ],
  ]),
], { autoStart: false })).toEqualBindingsStream([
  BF.bindings([
    [ DF.variable('a'), DF.namedNode('a1') ],
    [ DF.variable('b'), DF.namedNode('b1') ],
  ]),
  BF.bindings([
    [ DF.variable('b'), DF.namedNode('b1') ],
    [ DF.variable('c'), DF.namedNode('c1') ],
  ]),
]);
3.0.3

27 days ago

3.0.1

2 months ago

3.0.1-alpha.46.0

2 months ago

3.0.1-alpha.45.0

3 months ago

3.0.1-alpha.44.0

3 months ago

3.0.1-alpha.43.0

3 months ago

2.10.1

5 months ago

2.8.1

10 months ago

2.8.0

10 months ago

2.10.0

7 months ago

2.8.2

9 months ago

2.7.0

12 months ago

2.6.9

1 year ago

2.6.8

1 year ago

2.6.0

1 year ago

2.6.7

1 year ago

2.5.0

1 year ago

2.5.1

1 year ago

2.4.0

2 years ago

2.3.1-alpha.30.0

2 years ago

2.3.1-alpha.31.0

2 years ago

2.2.2-alpha.19.0

2 years ago

2.2.2-alpha.18.0

2 years ago

2.3.1-alpha.23.0

2 years ago

2.2.2-alpha.17.0

2 years ago

2.3.1-alpha.24.0

2 years ago

2.2.2-alpha.16.0

2 years ago

2.3.1-alpha.21.0

2 years ago

2.2.2-alpha.15.0

2 years ago

2.3.1-alpha.22.0

2 years ago

2.2.2-alpha.14.0

2 years ago

2.3.1-alpha.27.0

2 years ago

2.2.2-alpha.13.0

2 years ago

2.3.1-alpha.28.0

2 years ago

2.2.2-alpha.12.0

2 years ago

2.3.1-alpha.25.0

2 years ago

2.2.2-alpha.11.0

2 years ago

2.3.1-alpha.26.0

2 years ago

2.3.1-alpha.29.0

2 years ago

2.3.0

2 years ago

2.2.2-alpha.20.0

2 years ago

2.2.0

2 years ago

2.0.7-alpha.10.0

2 years ago

2.0.1

2 years ago

2.0.1-alpha.9.0

2 years ago

2.0.1-alpha.8.0

2 years ago

2.0.1-alpha.7.0

2 years ago

2.0.1-alpha.6.0

2 years ago

2.0.1-alpha.5.0

2 years ago