Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "_id" : 123456,
- "mykey" : 2
- }
- import * as chai from 'chai';
- import * as chaiAsPromised from 'chai-as-promised';
- chai.use(chaiAsPromised);
- const expect = chai.expect;
- module.exports = function () {
- this.Then(/^Data should be same$/, function (callback) {
- // Connection to mongoDB
- const MongoClient = require('mongodb').MongoClient;
- MongoClient.connect('mongodb://localhost:8517/fpl').then(function(db) {
- const collection = db.collection('test');
- // Test data
- const testData = [{
- _id: 123456,
- mykey: 2
- }];
- // Query to DB for data
- const a = collection.find({_id: 123456}).toArray();
- // "is data from DB == test data?"
- return expect(a).to.eventually.equal(testData).notify(callback);
- }).catch((err) => {
- console.log(err);
- });
- Message:
- AssertionError: expected [ { _id: 123456, mykey: 2 } ] to equal [ { _id: 123456, mykey: 2 } ]
- 1 scenario (1 failed)
- 1 step (1 failed)
- 0m00.094s
- AssertionError: expected [ { _id: 123456, mykey: 2 } ] to equal [ { _id: 123456, mykey: 2 } ]
- message: 'expected [ { _id: 123456, mykey: 2 } ] to equal [ { _id: 123456, mykey: 2 } ]',
- showDiff: true,
- actual: [ { _id: 123456, mykey: 2 } ],
- expected: [ { _id: 123456, mykey: 2 } ] }
- [14:22:34] I/local - Shutting down selenium standalone server.
- [14:22:34] I/launcher - 0 instance(s) of WebDriver still running
- [14:22:34] I/launcher - chrome #01 failed 1 test(s)
- [14:22:34] I/launcher - overall: 1 failed spec(s)
- [14:22:34] E/launcher - Process exited with error code 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement