forked from pumbaEO/gherkin-autocomplete
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Добавил базовый код для выполнения тестов
- Loading branch information
Showing
4 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"use strict"; | ||
|
||
import * as fs from "fs"; | ||
import * as glob from "glob"; | ||
import * as paths from "path"; | ||
|
||
const Mocha = require("mocha"); | ||
|
||
// Linux: prevent a weird NPE when mocha on Linux requires the window size from the TTY | ||
// Since we are not running in a tty environment, we just implementt he method statically | ||
const tty = require("tty"); | ||
if (!tty.getWindowSize) { | ||
tty.getWindowSize = (): number[] => { | ||
return [80, 75]; | ||
}; | ||
} | ||
|
||
let mocha = new Mocha({ | ||
ui: "bdd", | ||
useColors: true, | ||
}); | ||
|
||
function configure(mochaOpts): void { | ||
mocha = new Mocha(mochaOpts); | ||
} | ||
exports.configure = configure; | ||
|
||
function run(testsRoot, clb): any { | ||
// Enable source map support | ||
|
||
// Glob test files | ||
glob("**/**.test.js", { cwd: testsRoot }, (error, files): any => { | ||
if (error) { | ||
return clb(error); | ||
} | ||
try { | ||
// Fill into Mocha | ||
files.forEach((f): Mocha => { | ||
return mocha.addFile(paths.join(testsRoot, f)); | ||
}); | ||
// Run the tests | ||
let failureCount = 0; | ||
|
||
mocha.run() | ||
.on("fail", (): void => { | ||
failureCount++; | ||
}) | ||
.on("end", (): void => { | ||
clb(undefined, failureCount); | ||
}); | ||
} catch (error) { | ||
return clb(error); | ||
} | ||
}); | ||
} | ||
exports.run = run; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters