Socket
Socket
Sign inDemoInstall

jest-teamcity

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-teamcity - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

__tests__/data.json

109

lib/index.js
/**
* @author Ivan Tereshchenkov
*/
const parsec = require('parsec');
const _ = require('lodash');
const internal = {
/**
* Escape text message to be compatible with Teamcity
* @param {string} str
* @returns {string}
*/
escape(str) {
if (!str) {
return '';
}
'use strict';
return str
.toString()
.replace(/\x1B.*?m/g, '')
.replace(/\|/g, '||')
.replace(/\n/g, '|n')
.replace(/\r/g, '|r')
.replace(/\[/g, '|[')
.replace(/\]/g, '|]')
.replace(/\u0085/g, '|x')
.replace(/\u2028/g, '|l')
.replace(/\u2029/g, '|p')
.replace(/'/g, '|\'')
},
const formatter = require('./formatter');
/**
* Prints test message
* @param {object} test
*/
printTestLog(tests) {
Object.keys(tests).forEach((suiteName) => {
if (suiteName === '_tests_') {
// print test details
tests[suiteName].forEach((test) => {
this.log(`##teamcity[testStarted name='${this.escape(test.title)}' captureStandardOutput='true']`);
switch (test.status) {
case 'failed':
test.failureMessages.forEach((error) => {
const [message, stack] = error.split('\n ');
this.log(`##teamcity[testFailed name='${this.escape(test.title)}' message='${this.escape(message)}' details='${this.escape(stack)}' captureStandardOutput='true']`);
});
break;
case 'pending':
this.log(`##teamcity[testIgnored name='${this.escape(test.title)}' message='pending']`);
break;
case 'passed':
break;
}
this.log(`##teamcity[testFinished name='${this.escape(test.title)}' duration='${test.duration}']`);
});
} else {
// print suite names
this.log(`##teamcity[testSuiteStarted name='${this.escape(suiteName)}']`);
this.printTestLog(tests[suiteName]);
this.log(`##teamcity[testSuiteFinished name='${this.escape(suiteName)}']`);
}
});
},
/**
* Outputs teamcity service message
* @param {string} text
*/
log(text) {
console.log(text);
},
/**
* Collects test suites
* @param {array} testResults
* @returns {object}
*/
collectSuites(testResults) {
const suites = {};
testResults.forEach((testFile) => {
testFile.testResults.forEach((test) => {
const path = test.ancestorTitles.join('.') + '._tests_';
if (!_.has(suites, path )) {
_.set(suites, path, []);
}
const testsList = _.get(suites, path);
testsList.push(test);
_.set(suites, path, testsList);
});
});
return suites;
},
/**
* Formats and outputs tests results
* @param {array} testResults
*/
formatReport(testResults) {
const suites = this.collectSuites(testResults);
this.printTestLog(suites);
}
};
module.exports = (result) => {
if (!parsec().teamcity) {
if (!process.env.TEAMCITY_VERSION) {
return result;
}
return internal.formatReport(result.testResults);
return formatter.formatReport(result.testResults);
};
{
"name": "jest-teamcity",
"version": "1.0.0",
"description": "Jest Teamcity Reporter",
"version": "1.1.0",
"description": "Teamcity Reporter for Jest Testing framework",
"homepage": "https://github.com/itereshchenkov/jest-teamcity",
"main": "lib/index.js",
"dependencies": {
"lodash": "^4.17.3",
"parsec": "^1.5.3"
"lodash": "^4.17.3"
},
"devDependencies": {
"eslint": "^3.12.2"
"eslint": "^3.12.2",
"jest": "^19.0.2"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest"
},

@@ -22,3 +22,7 @@ "keywords": [

"tests",
"unit"
"unit",
"unittest",
"integration",
"ci",
"cd"
],

@@ -25,0 +29,0 @@ "author": {

# jest-teamcity
TeamCity Reporter for Jest testing framework which groups tests using TeamCity Test Suites.
[![Build Status](https://travis-ci.org/itereshchenkov/jest-teamcity.svg?branch=master)](https://travis-ci.org/itereshchenkov/jest-teamcity)
TeamCity Reporter for Jest testing framework which groups tests using TeamCity Test Suites.
## Features

@@ -17,3 +19,3 @@

Put this into jest configuration file or package.json
```
```javascript
"jest": {

@@ -24,2 +26,10 @@ "testResultsProcessor": "jest-teamcity"

The reported is enabled only if `TEAMCITY_VERSION` variable is set. It should work in TeamCity be default.
To be able to run the tests with the reporter locally, environment variable should be set:
```bash
export TEAMCITY_VERSION="some_version"
```
To enable TeamCity reporter, use the following option:

@@ -29,6 +39,5 @@ `jest --teamcity`

Package.json example:
```
```javascript
"scripts": {
"test": "jest",
"test:teamcity": "jest --teamcity"
"test": "jest"
}

@@ -35,0 +44,0 @@ ```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc