Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: bluelovers ka
Added: Nov 30, 2017 3:34 PM
Modified: Jul 19, 2019 6:20 AM
Views: 34
Tags: chai dev mocha test
  1. // @ts-ignore
  2. import _chai = require('chai');
  3. // @ts-ignore
  4. // @ts-ignore
  5. //import { expect, assert } from 'chai';
  6.  
  7. // @ts-ignore
  8. import { IChaiInstalled } from 'chai-asserttype-extra'
  9. //import ChaiPlugin = require('chai-asserttype-extra');
  10. // @ts-ignore
  11. import ChaiStatic = Chai.ChaiStatic;
  12.  
  13. // @ts-ignore
  14. let chai: IChaiInstalled<ChaiStatic> | ChaiStatic;
  15.  
  16. if (requireResolve('chai-asserttype-extra'))
  17. {
  18.         // @ts-ignore
  19.         const ChaiPlugin = require('chai-asserttype-extra').ChaiPlugin;
  20.  
  21.         // @ts-ignore
  22.         chai = ChaiPlugin.install(_chai) as IChaiInstalled<ChaiStatic>;
  23. }
  24. else
  25. {
  26.         chai = _chai;
  27. }
  28.  
  29. if (requireResolve('chai-string'))
  30. {
  31.         // @ts-ignore
  32.         chai.use(require('chai-string'));
  33. }
  34.  
  35. const { expect, assert } = chai;
  36.  
  37. export { chai, expect, assert }
  38.  
  39. // @ts-ignore
  40. export const SymbolLogOutput = Symbol('output');
  41.  
  42. // @ts-ignore
  43. import path = require('path');
  44. // @ts-ignore
  45. import util = require('util');
  46.  
  47. // @ts-ignore
  48. (util.inspect.defaultOptions = util.inspect.defaultOptions || {}).colors = true;
  49.  
  50. export { path, util };
  51.  
  52. // @ts-ignore
  53. export const rootDir: string = path.join(__dirname, '..');
  54.  
  55. export function relative(filename: string): string
  56. {
  57.         // @ts-ignore
  58.         return path.relative(rootDir, filename);
  59. }
  60.  
  61. export function mochaAsync(fn: Function)
  62. {
  63.         return async (done) =>
  64.         {
  65.                 try
  66.                 {
  67.                         await fn();
  68.                         done();
  69.                 }
  70.                 catch (err)
  71.                 {
  72.                         done(err);
  73.                 }
  74.         };
  75. }
  76.  
  77. // @ts-ignore
  78. export default exports as typeof import('./_local-dev');
  79.  
  80. export function requireResolve(name: string): string
  81. {
  82.         try
  83.         {
  84.                 // @ts-ignore
  85.                 return require.resolve(name)
  86.         }
  87.         catch (e)
  88.         {
  89.  
  90.         }
  91.         return null;
  92. }
  93.