Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. {
  2. "_id" : 123456,
  3. "mykey" : 2
  4. }
  5.  
  6. import * as chai from 'chai';
  7. import * as chaiAsPromised from 'chai-as-promised';
  8. chai.use(chaiAsPromised);
  9. const expect = chai.expect;
  10.  
  11. module.exports = function () {
  12. this.Then(/^Data should be same$/, function (callback) {
  13.  
  14. // Connection to mongoDB
  15.  
  16. const MongoClient = require('mongodb').MongoClient;
  17. MongoClient.connect('mongodb://localhost:8517/fpl').then(function(db) {
  18.  
  19. const collection = db.collection('test');
  20.  
  21. // Test data
  22.  
  23. const testData = [{
  24. _id: 123456,
  25. mykey: 2
  26. }];
  27.  
  28. // Query to DB for data
  29.  
  30. const a = collection.find({_id: 123456}).toArray();
  31.  
  32. // "is data from DB == test data?"
  33.  
  34. return expect(a).to.eventually.equal(testData).notify(callback);
  35.  
  36.  
  37. }).catch((err) => {
  38. console.log(err);
  39. });
  40.  
  41. Message:
  42. AssertionError: expected [ { _id: 123456, mykey: 2 } ] to equal [ { _id: 123456, mykey: 2 } ]
  43.  
  44. 1 scenario (1 failed)
  45. 1 step (1 failed)
  46. 0m00.094s
  47. AssertionError: expected [ { _id: 123456, mykey: 2 } ] to equal [ { _id: 123456, mykey: 2 } ]
  48. message: 'expected [ { _id: 123456, mykey: 2 } ] to equal [ { _id: 123456, mykey: 2 } ]',
  49. showDiff: true,
  50. actual: [ { _id: 123456, mykey: 2 } ],
  51. expected: [ { _id: 123456, mykey: 2 } ] }
  52. [14:22:34] I/local - Shutting down selenium standalone server.
  53. [14:22:34] I/launcher - 0 instance(s) of WebDriver still running
  54. [14:22:34] I/launcher - chrome #01 failed 1 test(s)
  55. [14:22:34] I/launcher - overall: 1 failed spec(s)
  56. [14:22:34] E/launcher - Process exited with error code 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement