Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. 1) "before all" hook
  2.  
  3. 0 passing (2s)
  4. 1 failing
  5.  
  6. 1) "before all" hook:
  7. Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  8.  
  9. const rewiremock = require("rewiremock").default;
  10. const sinon = require("sinon");
  11.  
  12. // Some more imports
  13.  
  14. let readFileSync;
  15. let serverConfiguration;
  16. let testingModule;
  17.  
  18. before(
  19. function ()
  20. {
  21. // Some mocking of the form:
  22.  
  23. rewiremock(
  24. "fs"
  25. ).by(
  26. (
  27. mock
  28. ) =>
  29. {
  30. const realFs = mock.requireActual("fs");
  31. readFileSync = sinon.spy(realFs, "readFileSync");
  32.  
  33. return realFs;
  34. }
  35. );
  36.  
  37. const originalModule = require("./path/to/my/mod");
  38.  
  39. const fakeModule = {
  40. myMethod() {
  41. // Some behaviour-altering code and then:
  42. originalModule.myMethod();
  43. }
  44. };
  45.  
  46. testingModule = rewiremock.proxy(
  47. "./path/to/testing/module",
  48. {
  49. "./path/to/my/mod" : fakeHttpUiServerFactory
  50. }
  51. );
  52.  
  53. console.log("one");
  54.  
  55. // Some more mocking
  56.  
  57. console.log("two");
  58.  
  59. // Aaaand more mocking
  60.  
  61. console.log("three");
  62.  
  63. // Initialization of a configuration object
  64.  
  65. serverConfiguration = {
  66. "nothing" : "special here"
  67. };
  68.  
  69. console.log("four");
  70. }
  71. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement