- Notifications
You must be signed in to change notification settings - Fork48
License
travisjeffery/mocha-teamcity-reporter
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
mocha-teamcity-reporter
Teamcity reporter which makes it possible to display test results in real-time, makes test informationavailable on the Tests tab of the Build Results page.
- Breaking: Only supported on node.js 6 and above
- Breaking: Only Mocha version 6 and above is now supported
- Please remain on
mocha-teamcity-reporter@3
if this is an issue
- Please remain on
- New reporter option
ignoreHookWithName
to skip reporting for hooks with title containing some word (@DJ-Glock) - Added postfix _hook for flowId for hooks to ensure flowIds will never intersect.
- Implement 'hook end' event (@DJ-GLock)
- General maintenance and tidy up (@DJ-Glock)
- recordHookFailures option may not work as intended as mocha6 is now doing this itself
- NodeJs 6+
- Mocha 6+
- Web Browser supporting ES5
In your project run a npm install command:
npm install mocha-teamcity-reporter --save-dev
Basically, have your project's package.json be like:
{"devDependencies":{"mocha-teamcity-reporter":">=2.0.0"}}
https://github.com/visionmedia/mocha/wiki/Third-party-reporters describes using third party reporters in mocha.
Then call mocha with:
mocha --reporter mocha-teamcity-reporter test
- Use
lib/teamcityBrowser
- Has option parsing stripped out for the moment
- Example use can be found in
test\browser
- Custom log function can be set with window.customLogFunction
Can set flowId like:mocha test --reporter mocha-teamcity-reporter --reporter-options flowId=gobbledygook
Can set a top-level suite name, which will wrap all other suites.
This is useful for reading test output when running multiple suites in a single build
- Environment variable: MOCHA_TEAMCITY_TOP_LEVEL_SUITE=
- Reporter option: topLevelSuite=
To enable this pleasePlease note this will probaly be made default in the next major version
- Environment variable: USE_STD_ERROR=true
- Reporter option: useStdError=true
Record failures for hooks such as before/after etcPlease note this will probably be made default in the next major version
- Environment variable: RECORD_HOOK_FAILURES=true
- Reporter option: recordHookFailures=true
Display skip tests as ignored
- Environment variable: DISPLAY_IGNORED_AS_IGNORED=true
- Reporter option: displayIgnoredAsIgnored=true
This option should be used in pair with recordHookFailures. It allows you to skip reporting of hooks containing some word. Including root hooks.
- Environment variable: IGNORE_HOOK_WITH_NAME=HookNoReporting
- Reporter option: ignoreHookWithName=HookNoReporting
Example:mocha test --reporter mocha-teamcity-reporter --reporter-options recordHookFailures --reporter-options ignoreHookWithName=HookNoReporting
For root hooks defined the following way:
exports.mochaHooks = () => { return { beforeEach: [ function beforeEachRootHookNoReporting() { assert.strictEqual(1, 1); } ], afterEach: [ function afterEachRoot() { assert.strictEqual(1, 1); }, ] };};
beforeEach hook beforeEachRootHookNoReporting() will not be reported as testStarted. But hook afterEachRoot() will be reported:
This will allow a hyperlink to appear to compare actual vs expectedPlease note this requires the error thrown in mocha to have the properties actual and expected. For example an assertionError has this
- Environment variable: ACTUAL_VS_EXPECTED=true
- Reporter option: actualVsExpected=true
This will be shown in teamcity like this:
AssertionError [ERR_ASSERTION]: 2 == 1 at Context.<anonymous> (test/test_data/simple.js:11:11) ======= Failed test run #10 ========== Show diff between expected and actual values
- Set with reporter-options:
mocha test --reporter mocha-teamcity-reporter --reporter-options topLevelSuite=top-level-suite-name
mocha test --reporter mocha-teamcity-reporter --reporter-options useStdError=true
mocha test --reporter mocha-teamcity-reporter --reporter-options useStdError=true
- Set with environment variable
MOCHA_TEAMCITY_TOP_LEVEL_SUITE='top-level-suite-name' mocha test --reporter mocha-teamcity-reporter
This is not supported out of the box by this plugin but have a look at the following:
- Usinghttps://github.com/stanleyhlng/mocha-multi-reporters
- https://stackoverflow.com/questions/11354203/is-it-possible-to-get-the-raw-build-log-from-a-teamcity-build/67635511#67635511
- Or view#60 for more details
- Project can be viewed atPubic Teamcity at Jetbrains mocha reporter
- Thanks to JetBrains for hosting
- Always Welcome
- Would prefer if customisation is added it is controlled via mocha options or environment variables
- Only requirement is for code to pass linting and functional tests
mocha test/test_data/simple.js --reporter mocha-teamcity-reporter
ornpm run test-teamcity-example
https://confluence.jetbrains.com/display/TCD10/Build+Script+Interaction+with+TeamCity
About
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Contributors13
Uh oh!
There was an error while loading.Please reload this page.