Best JavaScript code snippet using mocha
mocha_v4.x.x.js
Source:mocha_v4.x.x.js
1// flow-typed signature: e8d50d58f9d96065d29f810f297eaeb22// flow-typed version: 883196e42b/mocha_v4.x.x/flow_>=v0.28.x3declare interface $npm$mocha$SetupOptions {4 slow?: number;5 timeout?: number;6 ui?: string;7 globals?: Array<any>;8 reporter?: any;9 bail?: boolean;10 ignoreLeaks?: boolean;11 grep?: any;12}13declare type $npm$mocha$done = (error?: any) => any14// declare interface $npm$mocha$SuiteCallbackContext {15// timeout(ms: number): void;16// retries(n: number): void;17// slow(ms: number): void;18// }19// declare interface $npm$mocha$TestCallbackContext {20// skip(): void;21// timeout(ms: number): void;22// retries(n: number): void;23// slow(ms: number): void;24// [index: string]: any;25// }26declare interface $npm$mocha$Suite {27 parent: $npm$mocha$Suite;28 title: string;29 fullTitle(): string;30}31declare interface $npm$mocha$ContextDefinition {32 (33 description: string,34 callback: () => /* this: $npm$mocha$SuiteCallbackContext */ void35 ): $npm$mocha$Suite;36 only(37 description: string,38 callback: () => /* this: $npm$mocha$SuiteCallbackContext */ void39 ): $npm$mocha$Suite;40 skip(41 description: string,42 callback: () => /* this: $npm$mocha$SuiteCallbackContext */ void43 ): void;44 timeout(ms: number): void;45}46declare interface $npm$mocha$TestDefinition {47 (48 expectation: string,49 callback?: (50 /* this: $npm$mocha$TestCallbackContext, */ done: $npm$mocha$done51 ) => mixed52 ): $npm$mocha$Test;53 only(54 expectation: string,55 callback?: (56 /* this: $npm$mocha$TestCallbackContext, */ done: $npm$mocha$done57 ) => mixed58 ): $npm$mocha$Test;59 skip(60 expectation: string,61 callback?: (62 /* this: $npm$mocha$TestCallbackContext, */ done: $npm$mocha$done63 ) => mixed64 ): void;65 timeout(ms: number): void;66 state: 'failed' | 'passed';67}68declare interface $npm$mocha$Runner {}69declare class $npm$mocha$BaseReporter {70 stats: {71 suites: number,72 tests: number,73 passes: number,74 pending: number,75 failures: number,76 };77 constructor(runner: $npm$mocha$Runner): $npm$mocha$BaseReporter;78}79declare class $npm$mocha$DocReporter extends $npm$mocha$BaseReporter {}80declare class $npm$mocha$DotReporter extends $npm$mocha$BaseReporter {}81declare class $npm$mocha$HTMLReporter extends $npm$mocha$BaseReporter {}82declare class $npm$mocha$HTMLCovReporter extends $npm$mocha$BaseReporter {}83declare class $npm$mocha$JSONReporter extends $npm$mocha$BaseReporter {}84declare class $npm$mocha$JSONCovReporter extends $npm$mocha$BaseReporter {}85declare class $npm$mocha$JSONStreamReporter extends $npm$mocha$BaseReporter {}86declare class $npm$mocha$LandingReporter extends $npm$mocha$BaseReporter {}87declare class $npm$mocha$ListReporter extends $npm$mocha$BaseReporter {}88declare class $npm$mocha$MarkdownReporter extends $npm$mocha$BaseReporter {}89declare class $npm$mocha$MinReporter extends $npm$mocha$BaseReporter {}90declare class $npm$mocha$NyanReporter extends $npm$mocha$BaseReporter {}91declare class $npm$mocha$ProgressReporter extends $npm$mocha$BaseReporter {92 constructor(93 runner: $npm$mocha$Runner,94 options?: {95 open?: string,96 complete?: string,97 incomplete?: string,98 close?: string,99 }100 ): $npm$mocha$ProgressReporter;101}102declare class $npm$mocha$SpecReporter extends $npm$mocha$BaseReporter {}103declare class $npm$mocha$TAPReporter extends $npm$mocha$BaseReporter {}104declare class $npm$mocha$XUnitReporter extends $npm$mocha$BaseReporter {105 constructor(106 runner: $npm$mocha$Runner,107 options?: any108 ): $npm$mocha$XUnitReporter;109}110declare class $npm$mocha$Mocha {111 currentTest: $npm$mocha$TestDefinition;112 constructor(options?: {113 grep?: RegExp,114 ui?: string,115 reporter?: string,116 timeout?: number,117 reporterOptions?: any,118 slow?: number,119 bail?: boolean,120 }): $npm$mocha$Mocha;121 setup(options: $npm$mocha$SetupOptions): this;122 bail(value?: boolean): this;123 addFile(file: string): this;124 reporter(name: string): this;125 reporter(reporter: (runner: $npm$mocha$Runner, options: any) => any): this;126 ui(value: string): this;127 grep(value: string): this;128 grep(value: RegExp): this;129 invert(): this;130 ignoreLeaks(value: boolean): this;131 checkLeaks(): this;132 throwError(error: Error): void;133 growl(): this;134 globals(value: string): this;135 globals(values: Array<string>): this;136 useColors(value: boolean): this;137 useInlineDiffs(value: boolean): this;138 timeout(value: number): this;139 slow(value: number): this;140 enableTimeouts(value: boolean): this;141 asyncOnly(value: boolean): this;142 noHighlighting(value: boolean): this;143 run(onComplete?: (failures: number) => void): $npm$mocha$Runner;144 static reporters: {145 Doc: $npm$mocha$DocReporter,146 Dot: $npm$mocha$DotReporter,147 HTML: $npm$mocha$HTMLReporter,148 HTMLCov: $npm$mocha$HTMLCovReporter,149 JSON: $npm$mocha$JSONReporter,150 JSONCov: $npm$mocha$JSONCovReporter,151 JSONStream: $npm$mocha$JSONStreamReporter,152 Landing: $npm$mocha$LandingReporter,153 List: $npm$mocha$ListReporter,154 Markdown: $npm$mocha$MarkdownReporter,155 Min: $npm$mocha$MinReporter,156 Nyan: $npm$mocha$NyanReporter,157 Progress: $npm$mocha$ProgressReporter,158 };159}160// declare interface $npm$mocha$HookCallbackContext {161// skip(): void;162// timeout(ms: number): void;163// [index: string]: any;164// }165declare interface $npm$mocha$Runnable {166 title: string;167 fn: Function;168 async: boolean;169 sync: boolean;170 timedOut: boolean;171}172declare interface $npm$mocha$Test extends $npm$mocha$Runnable {173 parent: $npm$mocha$Suite;174 pending: boolean;175 state: 'failed' | 'passed' | void;176 fullTitle(): string;177}178// declare interface $npm$mocha$BeforeAndAfterContext extends $npm$mocha$HookCallbackContext {179// currentTest: $npm$mocha$Test;180// }181declare var mocha: $npm$mocha$Mocha182declare var describe: $npm$mocha$ContextDefinition183declare var xdescribe: $npm$mocha$ContextDefinition184declare var context: $npm$mocha$ContextDefinition185declare var suite: $npm$mocha$ContextDefinition186declare var it: $npm$mocha$TestDefinition187declare var xit: $npm$mocha$TestDefinition188declare var test: $npm$mocha$TestDefinition189declare var specify: $npm$mocha$TestDefinition190declare function run(): void191declare function setup(192 callback: (193 /* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done194 ) => mixed195): void196declare function teardown(197 callback: (198 /* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done199 ) => mixed200): void201declare function suiteSetup(202 callback: (203 /* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done204 ) => mixed205): void206declare function suiteTeardown(207 callback: (208 /* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done209 ) => mixed210): void211declare function before(212 callback: (213 /* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done214 ) => mixed215): void216declare function before(217 description: string,218 callback: (219 /* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done220 ) => mixed221): void222declare function after(223 callback: (224 /* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done225 ) => mixed226): void227declare function after(228 description: string,229 callback: (230 /* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done231 ) => mixed232): void233declare function beforeEach(234 callback: (235 /* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done236 ) => mixed237): void238declare function beforeEach(239 description: string,240 callback: (241 /* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done242 ) => mixed243): void244declare function afterEach(245 callback: (246 /* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done247 ) => mixed248): void249declare function afterEach(250 description: string,251 callback: (252 /* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done253 ) => mixed254): void255declare module 'mocha' {256 declare export var mocha: typeof mocha257 declare export var describe: typeof describe258 declare export var xdescribe: typeof xdescribe259 declare export var context: typeof context260 declare export var suite: typeof suite261 declare export var it: typeof it262 declare export var xit: typeof xit263 declare export var test: typeof test264 declare export var specify: typeof specify265 declare export var run: typeof run266 declare export var setup: typeof setup267 declare export var teardown: typeof teardown268 declare export var suiteSetup: typeof suiteSetup269 declare export var suiteTeardown: typeof suiteTeardown270 declare export var before: typeof before271 declare export var before: typeof before272 declare export var after: typeof after273 declare export var after: typeof after274 declare export var beforeEach: typeof beforeEach275 declare export var beforeEach: typeof beforeEach276 declare export var afterEach: typeof afterEach277 declare export var afterEach: typeof afterEach278 declare export default $npm$mocha$Mocha...
mocha_v6.x.x.js
Source:mocha_v6.x.x.js
1// flow-typed signature: 20b0652486d454dcf866e33655eab87e2// flow-typed version: 43576b1807/mocha_v6.x.x/flow_>=v0.28.x3declare interface $npm$mocha$SetupOptions {4 slow?: number;5 timeout?: number;6 ui?: string;7 globals?: Array<any>;8 reporter?: any;9 bail?: boolean;10 ignoreLeaks?: boolean;11 grep?: any;12}13declare type $npm$mocha$done = (error?: any) => any;14// declare interface $npm$mocha$SuiteCallbackContext {15// timeout(ms: number): void;16// retries(n: number): void;17// slow(ms: number): void;18// }19// declare interface $npm$mocha$TestCallbackContext {20// skip(): void;21// timeout(ms: number): void;22// retries(n: number): void;23// slow(ms: number): void;24// [index: string]: any;25// }26declare interface $npm$mocha$Suite {27 parent: $npm$mocha$Suite;28 title: string;29 fullTitle(): string;30}31declare interface $npm$mocha$ContextDefinition {32 (description: string, callback: (/* this: $npm$mocha$SuiteCallbackContext */) => void): $npm$mocha$Suite;33 only(description: string, callback: (/* this: $npm$mocha$SuiteCallbackContext */) => void): $npm$mocha$Suite;34 skip(description: string, callback: (/* this: $npm$mocha$SuiteCallbackContext */) => void): void;35 timeout(ms: number): void;36}37declare interface $npm$mocha$TestDefinition {38 (expectation: string, callback?: (/* this: $npm$mocha$TestCallbackContext, */ done: $npm$mocha$done) => mixed): $npm$mocha$Test;39 only(expectation: string, callback?: (/* this: $npm$mocha$TestCallbackContext, */ done: $npm$mocha$done) => mixed): $npm$mocha$Test;40 skip(expectation: string, callback?: (/* this: $npm$mocha$TestCallbackContext, */ done: $npm$mocha$done) => mixed): void;41 timeout(ms: number): void;42 state: 'failed' | 'passed';43}44declare interface $npm$mocha$Runner {}45declare class $npm$mocha$BaseReporter {46 stats: {47 suites: number;48 tests: number;49 passes: number;50 pending: number;51 failures: number;52 };53 constructor(runner: $npm$mocha$Runner): $npm$mocha$BaseReporter;54}55declare class $npm$mocha$DocReporter extends $npm$mocha$BaseReporter {}56declare class $npm$mocha$DotReporter extends $npm$mocha$BaseReporter {}57declare class $npm$mocha$HTMLReporter extends $npm$mocha$BaseReporter {}58declare class $npm$mocha$HTMLCovReporter extends $npm$mocha$BaseReporter {}59declare class $npm$mocha$JSONReporter extends $npm$mocha$BaseReporter {}60declare class $npm$mocha$JSONCovReporter extends $npm$mocha$BaseReporter {}61declare class $npm$mocha$JSONStreamReporter extends $npm$mocha$BaseReporter {}62declare class $npm$mocha$LandingReporter extends $npm$mocha$BaseReporter {}63declare class $npm$mocha$ListReporter extends $npm$mocha$BaseReporter {}64declare class $npm$mocha$MarkdownReporter extends $npm$mocha$BaseReporter {}65declare class $npm$mocha$MinReporter extends $npm$mocha$BaseReporter {}66declare class $npm$mocha$NyanReporter extends $npm$mocha$BaseReporter {}67declare class $npm$mocha$ProgressReporter extends $npm$mocha$BaseReporter {68 constructor(runner: $npm$mocha$Runner, options?: {69 open?: string;70 complete?: string;71 incomplete?: string;72 close?: string;73 }): $npm$mocha$ProgressReporter;74}75declare class $npm$mocha$SpecReporter extends $npm$mocha$BaseReporter {}76declare class $npm$mocha$TAPReporter extends $npm$mocha$BaseReporter {}77declare class $npm$mocha$XUnitReporter extends $npm$mocha$BaseReporter {78 constructor(runner: $npm$mocha$Runner, options?: any): $npm$mocha$XUnitReporter;79}80declare class $npm$mocha$Mocha {81 currentTest: $npm$mocha$TestDefinition;82 constructor(options?: {83 grep?: RegExp;84 ui?: string;85 reporter?: string;86 timeout?: number;87 reporterOptions?: any;88 slow?: number;89 bail?: boolean;90 }): $npm$mocha$Mocha;91 setup(options: $npm$mocha$SetupOptions): this;92 bail(value?: boolean): this;93 addFile(file: string): this;94 reporter(name: string): this;95 reporter(reporter: (runner: $npm$mocha$Runner, options: any) => any): this;96 ui(value: string): this;97 grep(value: string): this;98 grep(value: RegExp): this;99 invert(): this;100 ignoreLeaks(value: boolean): this;101 checkLeaks(): this;102 throwError(error: Error): void;103 growl(): this;104 globals(value: string): this;105 globals(values: Array<string>): this;106 useColors(value: boolean): this;107 useInlineDiffs(value: boolean): this;108 timeout(value: number): this;109 slow(value: number): this;110 enableTimeouts(value: boolean): this;111 asyncOnly(value: boolean): this;112 noHighlighting(value: boolean): this;113 run(onComplete?: (failures: number) => void): $npm$mocha$Runner;114 static reporters: {115 Doc: $npm$mocha$DocReporter,116 Dot: $npm$mocha$DotReporter,117 HTML: $npm$mocha$HTMLReporter,118 HTMLCov: $npm$mocha$HTMLCovReporter,119 JSON: $npm$mocha$JSONReporter,120 JSONCov: $npm$mocha$JSONCovReporter,121 JSONStream: $npm$mocha$JSONStreamReporter,122 Landing: $npm$mocha$LandingReporter,123 List: $npm$mocha$ListReporter,124 Markdown: $npm$mocha$MarkdownReporter,125 Min: $npm$mocha$MinReporter,126 Nyan: $npm$mocha$NyanReporter,127 Progress: $npm$mocha$ProgressReporter,128 };129}130// declare interface $npm$mocha$HookCallbackContext {131// skip(): void;132// timeout(ms: number): void;133// [index: string]: any;134// }135declare interface $npm$mocha$Runnable {136 title: string;137 fn: Function;138 async: boolean;139 sync: boolean;140 timedOut: boolean;141}142declare interface $npm$mocha$Test extends $npm$mocha$Runnable {143 parent: $npm$mocha$Suite;144 pending: boolean;145 state: 'failed' | 'passed' | void;146 fullTitle(): string;147 timeout(ms: number): void;148}149// declare interface $npm$mocha$BeforeAndAfterContext extends $npm$mocha$HookCallbackContext {150// currentTest: $npm$mocha$Test;151// }152declare var mocha: $npm$mocha$Mocha;153declare var describe: $npm$mocha$ContextDefinition;154declare var xdescribe: $npm$mocha$ContextDefinition;155declare var context: $npm$mocha$ContextDefinition;156declare var suite: $npm$mocha$ContextDefinition;157declare var it: $npm$mocha$TestDefinition;158declare var xit: $npm$mocha$TestDefinition;159declare var test: $npm$mocha$TestDefinition;160declare var specify: $npm$mocha$TestDefinition;161declare function run(): void;162declare function setup(callback: (/* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done) => mixed): void;163declare function teardown(callback: (/* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done) => mixed): void;164declare function suiteSetup(callback: (/* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done) => mixed): void;165declare function suiteTeardown(callback: (/* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done) => mixed): void;166declare function before(callback: (/* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done) => mixed): void;167declare function before(description: string, callback: (/* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done) => mixed): void;168declare function after(callback: (/* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done) => mixed): void;169declare function after(description: string, callback: (/* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done) => mixed): void;170declare function beforeEach(callback: (/* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done) => mixed): void;171declare function beforeEach(description: string, callback: (/* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done) => mixed): void;172declare function afterEach(callback: (/* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done) => mixed): void;173declare function afterEach(description: string, callback: (/* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done) => mixed): void;174declare module "mocha" {175 declare export var mocha: typeof mocha;176 declare export var describe: typeof describe;177 declare export var xdescribe: typeof xdescribe;178 declare export var context: typeof context;179 declare export var suite: typeof suite;180 declare export var it: typeof it;181 declare export var xit: typeof xit;182 declare export var test: typeof test;183 declare export var specify: typeof specify;184 declare export var run: typeof run;185 declare export var setup: typeof setup;186 declare export var teardown: typeof teardown;187 declare export var suiteSetup: typeof suiteSetup;188 declare export var suiteTeardown: typeof suiteTeardown;189 declare export var before: typeof before;190 declare export var before: typeof before;191 declare export var after: typeof after;192 declare export var after: typeof after;193 declare export var beforeEach: typeof beforeEach;194 declare export var beforeEach: typeof beforeEach;195 declare export var afterEach: typeof afterEach;196 declare export var afterEach: typeof afterEach;197 declare export default $npm$mocha$Mocha;...
mocha_v5.x.x.js
Source:mocha_v5.x.x.js
1// flow-typed signature: e8d50d58f9d96065d29f810f297eaeb22// flow-typed version: 883196e42b/mocha_v4.x.x/flow_>=v0.28.x3declare interface $npm$mocha$SetupOptions {4 slow?: number;5 timeout?: number;6 ui?: string;7 globals?: Array<any>;8 reporter?: any;9 bail?: boolean;10 ignoreLeaks?: boolean;11 grep?: any;12}13declare type $npm$mocha$done = (error?: any) => any;14// declare interface $npm$mocha$SuiteCallbackContext {15// timeout(ms: number): void;16// retries(n: number): void;17// slow(ms: number): void;18// }19// declare interface $npm$mocha$TestCallbackContext {20// skip(): void;21// timeout(ms: number): void;22// retries(n: number): void;23// slow(ms: number): void;24// [index: string]: any;25// }26declare interface $npm$mocha$Suite {27 parent: $npm$mocha$Suite;28 title: string;29 fullTitle(): string;30}31declare interface $npm$mocha$ContextDefinition {32 (description: string, callback: (/* this: $npm$mocha$SuiteCallbackContext */) => void): $npm$mocha$Suite;33 only(description: string, callback: (/* this: $npm$mocha$SuiteCallbackContext */) => void): $npm$mocha$Suite;34 skip(description: string, callback: (/* this: $npm$mocha$SuiteCallbackContext */) => void): void;35 timeout(ms: number): void;36}37declare interface $npm$mocha$TestDefinition {38 (expectation: string, callback?: (/* this: $npm$mocha$TestCallbackContext, */ done: $npm$mocha$done) => mixed): $npm$mocha$Test;39 only(expectation: string, callback?: (/* this: $npm$mocha$TestCallbackContext, */ done: $npm$mocha$done) => mixed): $npm$mocha$Test;40 skip(expectation: string, callback?: (/* this: $npm$mocha$TestCallbackContext, */ done: $npm$mocha$done) => mixed): void;41 timeout(ms: number): void;42 state: 'failed' | 'passed';43}44declare interface $npm$mocha$Runner {}45declare class $npm$mocha$BaseReporter {46 stats: {47 suites: number;48 tests: number;49 passes: number;50 pending: number;51 failures: number;52 };53 constructor(runner: $npm$mocha$Runner): $npm$mocha$BaseReporter;54}55declare class $npm$mocha$DocReporter extends $npm$mocha$BaseReporter {}56declare class $npm$mocha$DotReporter extends $npm$mocha$BaseReporter {}57declare class $npm$mocha$HTMLReporter extends $npm$mocha$BaseReporter {}58declare class $npm$mocha$HTMLCovReporter extends $npm$mocha$BaseReporter {}59declare class $npm$mocha$JSONReporter extends $npm$mocha$BaseReporter {}60declare class $npm$mocha$JSONCovReporter extends $npm$mocha$BaseReporter {}61declare class $npm$mocha$JSONStreamReporter extends $npm$mocha$BaseReporter {}62declare class $npm$mocha$LandingReporter extends $npm$mocha$BaseReporter {}63declare class $npm$mocha$ListReporter extends $npm$mocha$BaseReporter {}64declare class $npm$mocha$MarkdownReporter extends $npm$mocha$BaseReporter {}65declare class $npm$mocha$MinReporter extends $npm$mocha$BaseReporter {}66declare class $npm$mocha$NyanReporter extends $npm$mocha$BaseReporter {}67declare class $npm$mocha$ProgressReporter extends $npm$mocha$BaseReporter {68 constructor(runner: $npm$mocha$Runner, options?: {69 open?: string;70 complete?: string;71 incomplete?: string;72 close?: string;73 }): $npm$mocha$ProgressReporter;74}75declare class $npm$mocha$SpecReporter extends $npm$mocha$BaseReporter {}76declare class $npm$mocha$TAPReporter extends $npm$mocha$BaseReporter {}77declare class $npm$mocha$XUnitReporter extends $npm$mocha$BaseReporter {78 constructor(runner: $npm$mocha$Runner, options?: any): $npm$mocha$XUnitReporter;79}80declare class $npm$mocha$Mocha {81 currentTest: $npm$mocha$TestDefinition;82 constructor(options?: {83 grep?: RegExp;84 ui?: string;85 reporter?: string;86 timeout?: number;87 reporterOptions?: any;88 slow?: number;89 bail?: boolean;90 }): $npm$mocha$Mocha;91 setup(options: $npm$mocha$SetupOptions): this;92 bail(value?: boolean): this;93 addFile(file: string): this;94 reporter(name: string): this;95 reporter(reporter: (runner: $npm$mocha$Runner, options: any) => any): this;96 ui(value: string): this;97 grep(value: string): this;98 grep(value: RegExp): this;99 invert(): this;100 ignoreLeaks(value: boolean): this;101 checkLeaks(): this;102 throwError(error: Error): void;103 growl(): this;104 globals(value: string): this;105 globals(values: Array<string>): this;106 useColors(value: boolean): this;107 useInlineDiffs(value: boolean): this;108 timeout(value: number): this;109 slow(value: number): this;110 enableTimeouts(value: boolean): this;111 asyncOnly(value: boolean): this;112 noHighlighting(value: boolean): this;113 run(onComplete?: (failures: number) => void): $npm$mocha$Runner;114 static reporters: {115 Doc: $npm$mocha$DocReporter,116 Dot: $npm$mocha$DotReporter,117 HTML: $npm$mocha$HTMLReporter,118 HTMLCov: $npm$mocha$HTMLCovReporter,119 JSON: $npm$mocha$JSONReporter,120 JSONCov: $npm$mocha$JSONCovReporter,121 JSONStream: $npm$mocha$JSONStreamReporter,122 Landing: $npm$mocha$LandingReporter,123 List: $npm$mocha$ListReporter,124 Markdown: $npm$mocha$MarkdownReporter,125 Min: $npm$mocha$MinReporter,126 Nyan: $npm$mocha$NyanReporter,127 Progress: $npm$mocha$ProgressReporter,128 };129}130// declare interface $npm$mocha$HookCallbackContext {131// skip(): void;132// timeout(ms: number): void;133// [index: string]: any;134// }135declare interface $npm$mocha$Runnable {136 title: string;137 fn: Function;138 async: boolean;139 sync: boolean;140 timedOut: boolean;141}142declare interface $npm$mocha$Test extends $npm$mocha$Runnable {143 parent: $npm$mocha$Suite;144 pending: boolean;145 state: 'failed' | 'passed' | void;146 fullTitle(): string;147}148// declare interface $npm$mocha$BeforeAndAfterContext extends $npm$mocha$HookCallbackContext {149// currentTest: $npm$mocha$Test;150// }151declare var mocha: $npm$mocha$Mocha;152declare var describe: $npm$mocha$ContextDefinition;153declare var xdescribe: $npm$mocha$ContextDefinition;154declare var context: $npm$mocha$ContextDefinition;155declare var suite: $npm$mocha$ContextDefinition;156declare var it: $npm$mocha$TestDefinition;157declare var xit: $npm$mocha$TestDefinition;158declare var test: $npm$mocha$TestDefinition;159declare var specify: $npm$mocha$TestDefinition;160declare function run(): void;161declare function setup(callback: (/* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done) => mixed): void;162declare function teardown(callback: (/* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done) => mixed): void;163declare function suiteSetup(callback: (/* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done) => mixed): void;164declare function suiteTeardown(callback: (/* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done) => mixed): void;165declare function before(callback: (/* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done) => mixed): void;166declare function before(description: string, callback: (/* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done) => mixed): void;167declare function after(callback: (/* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done) => mixed): void;168declare function after(description: string, callback: (/* this: $npm$mocha$HookCallbackContext, */ done: $npm$mocha$done) => mixed): void;169declare function beforeEach(callback: (/* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done) => mixed): void;170declare function beforeEach(description: string, callback: (/* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done) => mixed): void;171declare function afterEach(callback: (/* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done) => mixed): void;172declare function afterEach(description: string, callback: (/* this: $npm$mocha$BeforeAndAfterContext, */ done: $npm$mocha$done) => mixed): void;173declare module "mocha" {174 declare export var mocha: typeof mocha;175 declare export var describe: typeof describe;176 declare export var xdescribe: typeof xdescribe;177 declare export var context: typeof context;178 declare export var suite: typeof suite;179 declare export var it: typeof it;180 declare export var xit: typeof xit;181 declare export var test: typeof test;182 declare export var specify: typeof specify;183 declare export var run: typeof run;184 declare export var setup: typeof setup;185 declare export var teardown: typeof teardown;186 declare export var suiteSetup: typeof suiteSetup;187 declare export var suiteTeardown: typeof suiteTeardown;188 declare export var before: typeof before;189 declare export var before: typeof before;190 declare export var after: typeof after;191 declare export var after: typeof after;192 declare export var beforeEach: typeof beforeEach;193 declare export var beforeEach: typeof beforeEach;194 declare export var afterEach: typeof afterEach;195 declare export var afterEach: typeof afterEach;196 declare export default $npm$mocha$Mocha;...
mocha_vx.x.x.js
Source:mocha_vx.x.x.js
1// flow-typed signature: 38661b84ffc02eab63d14345e5dd4ddc2// flow-typed version: <<STUB>>/mocha_v^3.0.2/flow_v0.68.03/**4 * This is an autogenerated libdef stub for:5 *6 * 'mocha'7 *8 * Fill this stub out by replacing all the `any` types.9 *10 * Once filled out, we encourage you to share your work with the11 * community by sending a pull request to:12 * https://github.com/flowtype/flow-typed13 */14declare module 'mocha' {15 declare module.exports: any;16}17/**18 * We include stubs for each file inside this npm package in case you need to19 * require those files directly. Feel free to delete any files that aren't20 * needed.21 */22declare module 'mocha/bin/options' {23 declare module.exports: any;24}25declare module 'mocha/browser-entry' {26 declare module.exports: any;27}28declare module 'mocha/lib/browser/debug' {29 declare module.exports: any;30}31declare module 'mocha/lib/browser/events' {32 declare module.exports: any;33}34declare module 'mocha/lib/browser/progress' {35 declare module.exports: any;36}37declare module 'mocha/lib/browser/tty' {38 declare module.exports: any;39}40declare module 'mocha/lib/context' {41 declare module.exports: any;42}43declare module 'mocha/lib/hook' {44 declare module.exports: any;45}46declare module 'mocha/lib/interfaces/bdd' {47 declare module.exports: any;48}49declare module 'mocha/lib/interfaces/common' {50 declare module.exports: any;51}52declare module 'mocha/lib/interfaces/exports' {53 declare module.exports: any;54}55declare module 'mocha/lib/interfaces/index' {56 declare module.exports: any;57}58declare module 'mocha/lib/interfaces/qunit' {59 declare module.exports: any;60}61declare module 'mocha/lib/interfaces/tdd' {62 declare module.exports: any;63}64declare module 'mocha/lib/mocha' {65 declare module.exports: any;66}67declare module 'mocha/lib/ms' {68 declare module.exports: any;69}70declare module 'mocha/lib/pending' {71 declare module.exports: any;72}73declare module 'mocha/lib/reporters/base' {74 declare module.exports: any;75}76declare module 'mocha/lib/reporters/doc' {77 declare module.exports: any;78}79declare module 'mocha/lib/reporters/dot' {80 declare module.exports: any;81}82declare module 'mocha/lib/reporters/html' {83 declare module.exports: any;84}85declare module 'mocha/lib/reporters/index' {86 declare module.exports: any;87}88declare module 'mocha/lib/reporters/json-stream' {89 declare module.exports: any;90}91declare module 'mocha/lib/reporters/json' {92 declare module.exports: any;93}94declare module 'mocha/lib/reporters/landing' {95 declare module.exports: any;96}97declare module 'mocha/lib/reporters/list' {98 declare module.exports: any;99}100declare module 'mocha/lib/reporters/markdown' {101 declare module.exports: any;102}103declare module 'mocha/lib/reporters/min' {104 declare module.exports: any;105}106declare module 'mocha/lib/reporters/nyan' {107 declare module.exports: any;108}109declare module 'mocha/lib/reporters/progress' {110 declare module.exports: any;111}112declare module 'mocha/lib/reporters/spec' {113 declare module.exports: any;114}115declare module 'mocha/lib/reporters/tap' {116 declare module.exports: any;117}118declare module 'mocha/lib/reporters/xunit' {119 declare module.exports: any;120}121declare module 'mocha/lib/runnable' {122 declare module.exports: any;123}124declare module 'mocha/lib/runner' {125 declare module.exports: any;126}127declare module 'mocha/lib/suite' {128 declare module.exports: any;129}130declare module 'mocha/lib/test' {131 declare module.exports: any;132}133declare module 'mocha/lib/to-iso-string/index' {134 declare module.exports: any;135}136declare module 'mocha/lib/utils' {137 declare module.exports: any;138}139declare module 'mocha/mocha' {140 declare module.exports: any;141}142// Filename aliases143declare module 'mocha/bin/options.js' {144 declare module.exports: $Exports<'mocha/bin/options'>;145}146declare module 'mocha/browser-entry.js' {147 declare module.exports: $Exports<'mocha/browser-entry'>;148}149declare module 'mocha/index' {150 declare module.exports: $Exports<'mocha'>;151}152declare module 'mocha/index.js' {153 declare module.exports: $Exports<'mocha'>;154}155declare module 'mocha/lib/browser/debug.js' {156 declare module.exports: $Exports<'mocha/lib/browser/debug'>;157}158declare module 'mocha/lib/browser/events.js' {159 declare module.exports: $Exports<'mocha/lib/browser/events'>;160}161declare module 'mocha/lib/browser/progress.js' {162 declare module.exports: $Exports<'mocha/lib/browser/progress'>;163}164declare module 'mocha/lib/browser/tty.js' {165 declare module.exports: $Exports<'mocha/lib/browser/tty'>;166}167declare module 'mocha/lib/context.js' {168 declare module.exports: $Exports<'mocha/lib/context'>;169}170declare module 'mocha/lib/hook.js' {171 declare module.exports: $Exports<'mocha/lib/hook'>;172}173declare module 'mocha/lib/interfaces/bdd.js' {174 declare module.exports: $Exports<'mocha/lib/interfaces/bdd'>;175}176declare module 'mocha/lib/interfaces/common.js' {177 declare module.exports: $Exports<'mocha/lib/interfaces/common'>;178}179declare module 'mocha/lib/interfaces/exports.js' {180 declare module.exports: $Exports<'mocha/lib/interfaces/exports'>;181}182declare module 'mocha/lib/interfaces/index.js' {183 declare module.exports: $Exports<'mocha/lib/interfaces/index'>;184}185declare module 'mocha/lib/interfaces/qunit.js' {186 declare module.exports: $Exports<'mocha/lib/interfaces/qunit'>;187}188declare module 'mocha/lib/interfaces/tdd.js' {189 declare module.exports: $Exports<'mocha/lib/interfaces/tdd'>;190}191declare module 'mocha/lib/mocha.js' {192 declare module.exports: $Exports<'mocha/lib/mocha'>;193}194declare module 'mocha/lib/ms.js' {195 declare module.exports: $Exports<'mocha/lib/ms'>;196}197declare module 'mocha/lib/pending.js' {198 declare module.exports: $Exports<'mocha/lib/pending'>;199}200declare module 'mocha/lib/reporters/base.js' {201 declare module.exports: $Exports<'mocha/lib/reporters/base'>;202}203declare module 'mocha/lib/reporters/doc.js' {204 declare module.exports: $Exports<'mocha/lib/reporters/doc'>;205}206declare module 'mocha/lib/reporters/dot.js' {207 declare module.exports: $Exports<'mocha/lib/reporters/dot'>;208}209declare module 'mocha/lib/reporters/html.js' {210 declare module.exports: $Exports<'mocha/lib/reporters/html'>;211}212declare module 'mocha/lib/reporters/index.js' {213 declare module.exports: $Exports<'mocha/lib/reporters/index'>;214}215declare module 'mocha/lib/reporters/json-stream.js' {216 declare module.exports: $Exports<'mocha/lib/reporters/json-stream'>;217}218declare module 'mocha/lib/reporters/json.js' {219 declare module.exports: $Exports<'mocha/lib/reporters/json'>;220}221declare module 'mocha/lib/reporters/landing.js' {222 declare module.exports: $Exports<'mocha/lib/reporters/landing'>;223}224declare module 'mocha/lib/reporters/list.js' {225 declare module.exports: $Exports<'mocha/lib/reporters/list'>;226}227declare module 'mocha/lib/reporters/markdown.js' {228 declare module.exports: $Exports<'mocha/lib/reporters/markdown'>;229}230declare module 'mocha/lib/reporters/min.js' {231 declare module.exports: $Exports<'mocha/lib/reporters/min'>;232}233declare module 'mocha/lib/reporters/nyan.js' {234 declare module.exports: $Exports<'mocha/lib/reporters/nyan'>;235}236declare module 'mocha/lib/reporters/progress.js' {237 declare module.exports: $Exports<'mocha/lib/reporters/progress'>;238}239declare module 'mocha/lib/reporters/spec.js' {240 declare module.exports: $Exports<'mocha/lib/reporters/spec'>;241}242declare module 'mocha/lib/reporters/tap.js' {243 declare module.exports: $Exports<'mocha/lib/reporters/tap'>;244}245declare module 'mocha/lib/reporters/xunit.js' {246 declare module.exports: $Exports<'mocha/lib/reporters/xunit'>;247}248declare module 'mocha/lib/runnable.js' {249 declare module.exports: $Exports<'mocha/lib/runnable'>;250}251declare module 'mocha/lib/runner.js' {252 declare module.exports: $Exports<'mocha/lib/runner'>;253}254declare module 'mocha/lib/suite.js' {255 declare module.exports: $Exports<'mocha/lib/suite'>;256}257declare module 'mocha/lib/test.js' {258 declare module.exports: $Exports<'mocha/lib/test'>;259}260declare module 'mocha/lib/to-iso-string/index.js' {261 declare module.exports: $Exports<'mocha/lib/to-iso-string/index'>;262}263declare module 'mocha/lib/utils.js' {264 declare module.exports: $Exports<'mocha/lib/utils'>;265}266declare module 'mocha/mocha.js' {267 declare module.exports: $Exports<'mocha/mocha'>;...
mocha-patch.js
Source:mocha-patch.js
1/**2* @license3* Copyright Google Inc. All Rights Reserved.4*5* Use of this source code is governed by an MIT-style license that can be6* found in the LICENSE file at https://angular.io/license7*/8(function (global, factory) {9 typeof exports === 'object' && typeof module !== 'undefined' ? factory() :10 typeof define === 'function' && define.amd ? define(factory) :11 (factory());12}(this, (function () { 'use strict';13/**14 * @license15 * Copyright Google Inc. All Rights Reserved.16 *17 * Use of this source code is governed by an MIT-style license that can be18 * found in the LICENSE file at https://angular.io/license19 */20(function (context) {21 var Mocha = context.Mocha;22 if (typeof Mocha === 'undefined') {23 throw new Error('Missing Mocha.js');24 }25 if (typeof Zone === 'undefined') {26 throw new Error('Missing Zone.js');27 }28 var ProxyZoneSpec = Zone['ProxyZoneSpec'];29 var SyncTestZoneSpec = Zone['SyncTestZoneSpec'];30 if (!ProxyZoneSpec) {31 throw new Error('Missing ProxyZoneSpec');32 }33 if (Mocha['__zone_patch__']) {34 throw new Error('"Mocha" has already been patched with "Zone".');35 }36 Mocha['__zone_patch__'] = true;37 var rootZone = Zone.current;38 var syncZone = rootZone.fork(new SyncTestZoneSpec('Mocha.describe'));39 var testZone = null;40 var suiteZone = rootZone.fork(new ProxyZoneSpec());41 var mochaOriginal = {42 after: Mocha.after,43 afterEach: Mocha.afterEach,44 before: Mocha.before,45 beforeEach: Mocha.beforeEach,46 describe: Mocha.describe,47 it: Mocha.it48 };49 function modifyArguments(args, syncTest, asyncTest) {50 var _loop_1 = function (i) {51 var arg = args[i];52 if (typeof arg === 'function') {53 // The `done` callback is only passed through if the function expects at54 // least one argument.55 // Note we have to make a function with correct number of arguments,56 // otherwise mocha will57 // think that all functions are sync or async.58 args[i] = (arg.length === 0) ? syncTest(arg) : asyncTest(arg);59 // Mocha uses toString to view the test body in the result list, make sure we return the60 // correct function body61 args[i].toString = function () {62 return arg.toString();63 };64 }65 };66 for (var i = 0; i < args.length; i++) {67 _loop_1(i);68 }69 return args;70 }71 function wrapDescribeInZone(args) {72 var syncTest = function (fn) {73 return function () {74 return syncZone.run(fn, this, arguments);75 };76 };77 return modifyArguments(args, syncTest);78 }79 function wrapTestInZone(args) {80 var asyncTest = function (fn) {81 return function (done) {82 return testZone.run(fn, this, [done]);83 };84 };85 var syncTest = function (fn) {86 return function () {87 return testZone.run(fn, this);88 };89 };90 return modifyArguments(args, syncTest, asyncTest);91 }92 function wrapSuiteInZone(args) {93 var asyncTest = function (fn) {94 return function (done) {95 return suiteZone.run(fn, this, [done]);96 };97 };98 var syncTest = function (fn) {99 return function () {100 return suiteZone.run(fn, this);101 };102 };103 return modifyArguments(args, syncTest, asyncTest);104 }105 context.describe = context.suite = Mocha.describe = function () {106 return mochaOriginal.describe.apply(this, wrapDescribeInZone(arguments));107 };108 context.xdescribe = context.suite.skip = Mocha.describe.skip = function () {109 return mochaOriginal.describe.skip.apply(this, wrapDescribeInZone(arguments));110 };111 context.describe.only = context.suite.only = Mocha.describe.only = function () {112 return mochaOriginal.describe.only.apply(this, wrapDescribeInZone(arguments));113 };114 context.it = context.specify = context.test = Mocha.it = function () {115 return mochaOriginal.it.apply(this, wrapTestInZone(arguments));116 };117 context.xit = context.xspecify = Mocha.it.skip = function () {118 return mochaOriginal.it.skip.apply(this, wrapTestInZone(arguments));119 };120 context.it.only = context.test.only = Mocha.it.only = function () {121 return mochaOriginal.it.only.apply(this, wrapTestInZone(arguments));122 };123 context.after = context.suiteTeardown = Mocha.after = function () {124 return mochaOriginal.after.apply(this, wrapSuiteInZone(arguments));125 };126 context.afterEach = context.teardown = Mocha.afterEach = function () {127 return mochaOriginal.afterEach.apply(this, wrapTestInZone(arguments));128 };129 context.before = context.suiteSetup = Mocha.before = function () {130 return mochaOriginal.before.apply(this, wrapSuiteInZone(arguments));131 };132 context.beforeEach = context.setup = Mocha.beforeEach = function () {133 return mochaOriginal.beforeEach.apply(this, wrapTestInZone(arguments));134 };135 (function (originalRunTest, originalRun) {136 Mocha.Runner.prototype.runTest = function (fn) {137 var _this = this;138 Zone.current.scheduleMicroTask('mocha.forceTask', function () {139 originalRunTest.call(_this, fn);140 });141 };142 Mocha.Runner.prototype.run = function (fn) {143 this.on('test', function (e) {144 if (Zone.current !== rootZone) {145 throw new Error('Unexpected zone: ' + Zone.current.name);146 }147 testZone = rootZone.fork(new ProxyZoneSpec());148 });149 return originalRun.call(this, fn);150 };151 })(Mocha.Runner.prototype.runTest, Mocha.Runner.prototype.run);152})(window);...
eslint-plugin-mocha_vx.x.x.js
Source:eslint-plugin-mocha_vx.x.x.js
1// flow-typed signature: 3a551edf7900d61a950a5049fe3385932// flow-typed version: <<STUB>>/eslint-plugin-mocha_v^4.8.0/flow_v0.38.03/**4 * This is an autogenerated libdef stub for:5 *6 * 'eslint-plugin-mocha'7 *8 * Fill this stub out by replacing all the `any` types.9 *10 * Once filled out, we encourage you to share your work with the 11 * community by sending a pull request to: 12 * https://github.com/flowtype/flow-typed13 */14declare module 'eslint-plugin-mocha' {15 declare module.exports: any;16}17/**18 * We include stubs for each file inside this npm package in case you need to19 * require those files directly. Feel free to delete any files that aren't20 * needed.21 */22declare module 'eslint-plugin-mocha/lib/rules/handle-done-callback' {23 declare module.exports: any;24}25declare module 'eslint-plugin-mocha/lib/rules/max-top-level-suites' {26 declare module.exports: any;27}28declare module 'eslint-plugin-mocha/lib/rules/no-exclusive-tests' {29 declare module.exports: any;30}31declare module 'eslint-plugin-mocha/lib/rules/no-global-tests' {32 declare module.exports: any;33}34declare module 'eslint-plugin-mocha/lib/rules/no-hooks-for-single-case' {35 declare module.exports: any;36}37declare module 'eslint-plugin-mocha/lib/rules/no-hooks' {38 declare module.exports: any;39}40declare module 'eslint-plugin-mocha/lib/rules/no-identical-title' {41 declare module.exports: any;42}43declare module 'eslint-plugin-mocha/lib/rules/no-mocha-arrows' {44 declare module.exports: any;45}46declare module 'eslint-plugin-mocha/lib/rules/no-nested-tests' {47 declare module.exports: any;48}49declare module 'eslint-plugin-mocha/lib/rules/no-pending-tests' {50 declare module.exports: any;51}52declare module 'eslint-plugin-mocha/lib/rules/no-return-and-callback' {53 declare module.exports: any;54}55declare module 'eslint-plugin-mocha/lib/rules/no-sibling-hooks' {56 declare module.exports: any;57}58declare module 'eslint-plugin-mocha/lib/rules/no-skipped-tests' {59 declare module.exports: any;60}61declare module 'eslint-plugin-mocha/lib/rules/no-synchronous-tests' {62 declare module.exports: any;63}64declare module 'eslint-plugin-mocha/lib/rules/no-top-level-hooks' {65 declare module.exports: any;66}67declare module 'eslint-plugin-mocha/lib/rules/valid-suite-description' {68 declare module.exports: any;69}70declare module 'eslint-plugin-mocha/lib/rules/valid-test-description' {71 declare module.exports: any;72}73declare module 'eslint-plugin-mocha/lib/util/ast' {74 declare module.exports: any;75}76declare module 'eslint-plugin-mocha/lib/util/settings' {77 declare module.exports: any;78}79// Filename aliases80declare module 'eslint-plugin-mocha/index' {81 declare module.exports: $Exports<'eslint-plugin-mocha'>;82}83declare module 'eslint-plugin-mocha/index.js' {84 declare module.exports: $Exports<'eslint-plugin-mocha'>;85}86declare module 'eslint-plugin-mocha/lib/rules/handle-done-callback.js' {87 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/handle-done-callback'>;88}89declare module 'eslint-plugin-mocha/lib/rules/max-top-level-suites.js' {90 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/max-top-level-suites'>;91}92declare module 'eslint-plugin-mocha/lib/rules/no-exclusive-tests.js' {93 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/no-exclusive-tests'>;94}95declare module 'eslint-plugin-mocha/lib/rules/no-global-tests.js' {96 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/no-global-tests'>;97}98declare module 'eslint-plugin-mocha/lib/rules/no-hooks-for-single-case.js' {99 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/no-hooks-for-single-case'>;100}101declare module 'eslint-plugin-mocha/lib/rules/no-hooks.js' {102 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/no-hooks'>;103}104declare module 'eslint-plugin-mocha/lib/rules/no-identical-title.js' {105 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/no-identical-title'>;106}107declare module 'eslint-plugin-mocha/lib/rules/no-mocha-arrows.js' {108 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/no-mocha-arrows'>;109}110declare module 'eslint-plugin-mocha/lib/rules/no-nested-tests.js' {111 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/no-nested-tests'>;112}113declare module 'eslint-plugin-mocha/lib/rules/no-pending-tests.js' {114 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/no-pending-tests'>;115}116declare module 'eslint-plugin-mocha/lib/rules/no-return-and-callback.js' {117 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/no-return-and-callback'>;118}119declare module 'eslint-plugin-mocha/lib/rules/no-sibling-hooks.js' {120 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/no-sibling-hooks'>;121}122declare module 'eslint-plugin-mocha/lib/rules/no-skipped-tests.js' {123 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/no-skipped-tests'>;124}125declare module 'eslint-plugin-mocha/lib/rules/no-synchronous-tests.js' {126 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/no-synchronous-tests'>;127}128declare module 'eslint-plugin-mocha/lib/rules/no-top-level-hooks.js' {129 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/no-top-level-hooks'>;130}131declare module 'eslint-plugin-mocha/lib/rules/valid-suite-description.js' {132 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/valid-suite-description'>;133}134declare module 'eslint-plugin-mocha/lib/rules/valid-test-description.js' {135 declare module.exports: $Exports<'eslint-plugin-mocha/lib/rules/valid-test-description'>;136}137declare module 'eslint-plugin-mocha/lib/util/ast.js' {138 declare module.exports: $Exports<'eslint-plugin-mocha/lib/util/ast'>;139}140declare module 'eslint-plugin-mocha/lib/util/settings.js' {141 declare module.exports: $Exports<'eslint-plugin-mocha/lib/util/settings'>;...
mocha.spec.js
Source:mocha.spec.js
...4describe('Mocha', function () {5 var blankOpts = { reporter: function () {} }; // no output6 describe('.run(fn)', function () {7 it('should not raise errors if callback was not provided', function () {8 var mocha = new Mocha(blankOpts);9 mocha.run();10 });11 it('should execute the callback when complete', function (done) {12 var mocha = new Mocha(blankOpts);13 mocha.run(function () {14 done();15 });16 });17 it('should execute the callback with the number of failures ' +18 'as parameter', function (done) {19 var mocha = new Mocha(blankOpts);20 var failingTest = new Test('failing test', function () {21 throw new Error('such fail');22 });23 mocha.suite.addTest(failingTest);24 mocha.run(function (failures) {25 expect(failures).to.equal(1);26 done();27 });28 });29 });30 describe('.addFile()', function () {31 it('should add the given file to the files array', function () {32 var mocha = new Mocha(blankOpts);33 mocha.addFile('myFile.js');34 expect(mocha.files.length).to.equal(1);35 expect(mocha.files[0]).to.equal('myFile.js');36 });37 });38 describe('.invert()', function () {39 it('should set the invert option to true', function () {40 var mocha = new Mocha(blankOpts);41 mocha.invert();42 expect(mocha.options.invert).to.equal(true);43 });44 it('should be chainable', function () {45 var mocha = new Mocha(blankOpts);46 expect(mocha.invert()).to.equal(mocha);47 });48 });49 describe('.ignoreLeaks()', function () {50 it('should set the ignoreLeaks option to true when param equals true', function () {51 var mocha = new Mocha(blankOpts);52 mocha.ignoreLeaks(true);53 expect(mocha.options.ignoreLeaks).to.equal(true);54 });55 it('should set the ignoreLeaks option to false when param equals false', function () {56 var mocha = new Mocha(blankOpts);57 mocha.ignoreLeaks(false);58 expect(mocha.options.ignoreLeaks).to.equal(false);59 });60 it('should set the ignoreLeaks option to false when the param is undefined', function () {61 var mocha = new Mocha(blankOpts);62 mocha.ignoreLeaks();63 expect(mocha.options.ignoreLeaks).to.equal(false);64 });65 it('should be chainable', function () {66 var mocha = new Mocha(blankOpts);67 expect(mocha.ignoreLeaks(false)).to.equal(mocha);68 });69 });70 describe('.checkLeaks()', function () {71 it('should set the ignoreLeaks option to false', function () {72 var mocha = new Mocha(blankOpts);73 mocha.checkLeaks();74 expect(mocha.options.ignoreLeaks).to.equal(false);75 });76 it('should be chainable', function () {77 var mocha = new Mocha(blankOpts);78 expect(mocha.checkLeaks()).to.equal(mocha);79 });80 });81 describe('.fullTrace()', function () {82 it('should set the fullStackTrace option to true', function () {83 var mocha = new Mocha(blankOpts);84 mocha.fullTrace();85 expect(mocha.options.fullStackTrace).to.equal(true);86 });87 it('should be chainable', function () {88 var mocha = new Mocha(blankOpts);89 expect(mocha.fullTrace()).to.equal(mocha);90 });91 });92 describe('.growl()', function () {93 it('should set the growl option to true', function () {94 var mocha = new Mocha(blankOpts);95 mocha.growl();96 expect(mocha.options.growl).to.equal(true);97 });98 it('should be chainable', function () {99 var mocha = new Mocha(blankOpts);100 expect(mocha.growl()).to.equal(mocha);101 });102 });103 describe('.useInlineDiffs()', function () {104 it('should set the useInlineDiffs option to true when param equals true', function () {105 var mocha = new Mocha(blankOpts);106 mocha.useInlineDiffs(true);107 expect(mocha.options.useInlineDiffs).to.equal(true);108 });109 it('should set the useInlineDiffs option to false when param equals false', function () {110 var mocha = new Mocha(blankOpts);111 mocha.useInlineDiffs(false);112 expect(mocha.options.useInlineDiffs).to.equal(false);113 });114 it('should set the useInlineDiffs option to false when the param is undefined', function () {115 var mocha = new Mocha(blankOpts);116 mocha.useInlineDiffs();117 expect(mocha.options.useInlineDiffs).to.equal(false);118 });119 it('should be chainable', function () {120 var mocha = new Mocha(blankOpts);121 expect(mocha.useInlineDiffs()).to.equal(mocha);122 });123 });124 describe('.noHighlighting()', function () {125 it('should set the noHighlighting option to true', function () {126 var mocha = new Mocha(blankOpts);127 mocha.noHighlighting();128 expect(mocha.options.noHighlighting).to.equal(true);129 });130 });131 describe('.allowUncaught()', function () {132 it('should set the allowUncaught option to true', function () {133 var mocha = new Mocha(blankOpts);134 mocha.allowUncaught();135 expect(mocha.options.allowUncaught).to.equal(true);136 });137 });138 describe('.delay()', function () {139 it('should set the delay option to true', function () {140 var mocha = new Mocha(blankOpts);141 mocha.delay();142 expect(mocha.options.delay).to.equal(true);143 });144 });145 describe('.bail()', function () {146 it('should set the suite._bail to true if there is no arguments', function () {147 var mocha = new Mocha({bail: false});148 expect(mocha.suite._bail).to.equal(false);149 mocha.bail();150 expect(mocha.suite._bail).to.equal(true);151 });152 });...
Gruntfile.js
Source:Gruntfile.js
1module.exports = function (grunt) {2 var fs = require('fs');3 var envPath = './.env.js';4 if (fs.existsSync(envPath)) {5 console.log("Adding environment variables");6 require(envPath);7 }8 var browsers = require('./test/browsers');9 var reporter = require('saucelabs-mocha-reporter');10 var gruntConfig = {11 pkg: grunt.file.readJSON('package.json'),12 jshint: {13 files: ['Gruntfile.js', 'src/*.js', 'test/**.js'],14 options: {15 laxbreak: true16 }17 },18 watch: {19 scripts: {20 files: ['<%= jshint.files %>'],21 tasks: ['jshint']22 }23 },24 connect: {25 server: {26 options: {27 port: 9000,28 hostname: '*',29 base: '.'30 }31 }32 },33 mocha_phantomjs: {34 test: {35 options: {36 urls: [37 'http://localhost:9000/test/mocha_test.html'38 ]39 }40 }41 },42 'saucelabs-mocha': {43 // Settings programatically added below44 }45 };46 var addTag = function(envVar) {47 var ev = process.env[envVar];48 if (ev && ev.length > 0) {49 if (ev === 'false' || ev === 'true') {50 if (ev === 'true') {51 tags.push(envVar);52 }53 } else {54 tags.push(ev);55 }56 }57 };58 var onTestComplete;59 for (var browser in browsers) {60 var taskBrowsers = browsers[browser];61 var tags = [];62 ['TRAVIS', 'TRAVIS_PULL_REQUEST', 'TRAVIS_BRANCH'].forEach(addTag);63 gruntConfig['saucelabs-mocha'][browser] = {64 options: {65 urls: ["http://127.0.0.1:9000/test/mocha_test.html"],66 tunnelTimeout: 5,67 build: process.env.TRAVIS_JOB_ID,68 tags: tags,69 concurrency: 3,70 browsers: taskBrowsers,71 testname: browser + ' mocha tests',72 'pollInterval': 1000,73 'max-duration': 6074 }75 };76 }77 grunt.initConfig(gruntConfig);78 grunt.loadNpmTasks('grunt-contrib-connect');79 grunt.loadNpmTasks('grunt-contrib-jshint');80 grunt.loadNpmTasks('grunt-contrib-watch');81 grunt.loadNpmTasks('grunt-mocha-phantomjs');82 grunt.loadNpmTasks('grunt-saucelabs');83 grunt.registerTask('default', ['connect', 'watch']);84 grunt.registerTask('test', 'Run tests', function (type, testType, multiple) {85 if(!type) {86 grunt.task.run(['connect', 'mocha_phantomjs']);87 } else if (browsers[type]) {88 var useTests = JSON.parse(testType || null);89 gruntConfig['saucelabs-mocha'][type].options.onTestComplete = reporter.create(useTests);90 if (type === 'ci') {91 gruntConfig['saucelabs-mocha'][type].options.statusCheckAttempts = 600;92 gruntConfig['saucelabs-mocha'][type].options['max-duration'] = 600;93 grunt.task.run(['connect', 'mocha_phantomjs', 'saucelabs-mocha:' + type]);94 } else {95 multiple = parseInt(multiple);96 if (multiple > 0) {97 var browserList = [];98 var configOptions = gruntConfig['saucelabs-mocha'][type].options;99 for(var i = 0; i < multiple; i++) {100 browserList.push.apply(browserList, configOptions.browsers);101 }102 configOptions.browsers = browserList;103 }104 grunt.task.run(['connect', 'saucelabs-mocha:' + type]);105 }106 } else {107 // Error!108 console.log("Couldn't find: " + type + " in browser config. Running phantomjs instead");109 grunt.task.run(['connect', 'mocha_phantomjs']);110 }111 });...
Using AI Code Generation
1const assert = require('assert');2const ganache = require('ganache-cli');3const Web3 = require('web3');4const web3 = new Web3(ganache.provider());5const { interface, bytecode } = require('../compile');6let lottery;7let accounts;8beforeEach(async () => {9 accounts = await web3.eth.getAccounts();10 lottery = await new web3.eth.Contract(JSON.parse(interface))11 .deploy({ data: bytecode })12 .send({ from: accounts[0], gas: '1000000' });13});14describe('Lottery Contract', () => {15 it('deploys a contract', () => {16 assert.ok(lottery.options.address);17 });18 it('allows one account to enter', async () => {19 await lottery.methods.enter().send({20 value: web3.utils.toWei('0.02', 'ether')21 });22 const players = await lottery.methods.getPlayers().call({23 });24 assert.equal(accounts[0], players[0]);25 assert.equal(1, players.length);26 });27 it('allows multiple accounts to enter', async () => {28 await lottery.methods.enter().send({29 value: web3.utils.toWei('0.02', 'ether')30 });31 await lottery.methods.enter().send({32 value: web3.utils.toWei('0.02', 'ether')33 });34 await lottery.methods.enter().send({35 value: web3.utils.toWei('0.02', 'ether')36 });37 const players = await lottery.methods.getPlayers().call({38 });39 assert.equal(accounts[0], players[0]);40 assert.equal(accounts[1], players[1]);41 assert.equal(accounts[2], players[2]);42 assert.equal(3, players.length);43 });44 it('requires a minimum amount of ether to enter', async () => {45 try {46 await lottery.methods.enter().send({47 });48 assert(false);49 } catch (err) {50 assert(err);51 }52 });53 it('only manager can call pick
Using AI Code Generation
1const assert = require('assert');2const ganache = require('ganache-cli');3const Web3 = require('web3');4const web3 = new Web3(ganache.provider());5const { interface, bytecode } = require('../compile');6let accounts;7let inbox;8beforeEach(async () => {9 accounts = await web3.eth.getAccounts();10 inbox = await new web3.eth.Contract(JSON.parse(interface))11 .deploy({ data: bytecode, arguments: ['Hi there!'] })12 .send({ from: accounts[0], gas: '1000000' });13});14describe('Inbox', () => {15 it('deploys a contract', () => {16 assert.ok(inbox.options.address);17 });18 it('has a default message', async () => {19 const message = await inbox.methods.message().call();20 assert.equal(message, 'Hi there!');21 });22 it('can change the message', async () => {23 await inbox.methods.setMessage('bye').send({ from: accounts[0] });24 const message = await inbox.methods.message().call();25 assert.equal(message, 'bye');26 });27});
Using AI Code Generation
1const assert = require('assert');2const MarioChar = require('../models/mariochar');3describe('Saving records', function(){4 it('Saves a record to the database', function(done){5 var char = new MarioChar({6 });7 char.save().then(function(){8 assert(char.isNew === false);9 done();10 });11 });12});13const mongoose = require('mongoose');14var Schema = mongoose.Schema;15var MarioCharSchema = new Schema({16});17var MarioChar = mongoose.model('mariochar', MarioCharSchema);18module.exports = MarioChar;
Using AI Code Generation
1var expect = require('chai').expect;2var request = require('request');3describe('Color Code Converter API', function() {4 describe('RGB to Hex conversion', function() {5 it('returns status 200', function(done) {6 request(url, function(error, response, body) {7 expect(response.statusCode).to.equal(200);8 done();9 });10 });11 it('returns the color in hex', function(done) {12 request(url, function(error, response, body) {13 expect(body).to.equal("ffffff");14 done();15 });16 });17 });18 describe('Hex to RGB conversion', function() {19 it('returns status 200', function(done) {20 request(url, function(error, response, body) {21 expect(response.statusCode).to.equal(200);22 done();23 });24 });25 it('returns the color in RGB', function(done) {26 request(url, function(error, response, body) {27 expect(body).to.equal("[0,255,0]");28 done();29 });30 });31 });32});33![Test-driven Development](./images/6.2.2.png)
Using AI Code Generation
1const assert = require('assert');2const add = require('../app.js');3describe('Array', function() {4 it('should return -1 when the value is not present', function() {5 assert.equal([1,2,3].indexOf(4), -1);6 });7});8function add(a, b) {9 return a + b;10}11module.exports = add;12The assert module has many methods. The assert.equal() method is used to compare the two values. The assert.deepEqual() method is used to compare the two objects. The assert.deepStrictEqual() method is used to compare the two objects. The assert.fail() method is used to fail the test case. The assert.ifError() method is used to check if the error is null or not. The assert.notDeepEqual() method is used to check if the two objects are not equal or not. The assert.notDeepStrictEqual() method is used to check if the two objects are not equal or not. The assert.notEqual() method is used to check if the two values are not equal or not. The assert.notStrictEqual() method is used to check if the two values are not equal or not. The assert.ok() method is used to check if the value is true or not. The assert.strictEqual() method is used
Using AI Code Generation
1var assert = require('assert');2var chai = require('chai');3var chaiHttp = require('chai-http');4var server = require('../server');5var should = chai.should();6chai.use(chaiHttp);7describe('Test Case 1: ', function() {8 it('should return a 200 status code', function(done) {9 chai.request(server)10 .get('/getdata')11 .end(function(err, res) {12 res.should.have.status(200);13 done();14 });15 });16});17describe('Test Case 2: ', function() {18 it('should return a 200 status code', function(done) {19 chai.request(server)20 .post('/postdata')21 .end(function(err, res) {22 res.should.have.status(200);23 done();24 });25 });26});27describe('Test Case 3: ', function() {28 it('should return a 200 status code', function(done) {29 chai.request(server)30 .put('/putdata')31 .end(function(err, res) {32 res.should.have.status(200);33 done();34 });35 });36});37describe('Test Case 4: ', function() {38 it('should return a 200 status code', function(done) {39 chai.request(server)40 .delete('/deletedata')41 .end(function(err, res) {42 res.should.have.status(200);43 done();44 });45 });46});47describe('Test Case 5: ', function() {48 it('should return a 200 status code', function(done) {49 chai.request(server)50 .get('/getdata')51 .end(function(err, res) {52 res.should.have.status(200);53 done();54 });55 });56});57describe('Test Case 6: ', function() {58 it('should return a 404 status code', function(done) {59 chai.request(server)60 .get('/getdata1')61 .end(function(err, res) {62 res.should.have.status(404);63 done();64 });65 });66});67describe('Test Case 7: ', function() {68 it('should return a 404 status code', function(done) {69 chai.request(server)70 .post('/postdata1')71 .end(function(err, res) {72 res.should.have.status(404);73 done();74 });75 });76});77describe('Test Case 8: ', function() {
Using AI Code Generation
1describe('Mocha', function() {2 it('should run our tests using npm', function() {3 expect(true).to.be.ok;4 });5});6describe('Mocha', function() {7 it('should run our tests using npm', function() {8 expect(true).to.be.ok;9 });10});11describe('Mocha', function() {12 it('should run our tests using npm', function() {13 expect(true).to.be.ok;14 });15});16describe('Mocha', function() {17 it('should run our tests using npm', function() {18 expect(true).to.be.ok;19 });20});21describe('Mocha', function() {22 it('should run our tests using npm', function() {23 expect(true).to.be.ok;24 });25});26describe('Mocha', function() {27 it('should run our tests using npm', function() {28 expect(true).to.be.ok;29 });30});31describe('Mocha', function() {32 it('should run our tests using npm', function() {33 expect(true).to.be.ok;34 });35});36describe('Mocha', function() {37 it('should run our tests using npm', function() {38 expect(true).to.be.ok;39 });40});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!