Skip to content

Commit

Permalink
refactor: use path to generate the suite msg
Browse files Browse the repository at this point in the history
  • Loading branch information
carpasse committed Nov 4, 2017
1 parent 026e561 commit 592e310
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/TapReporter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable id-match, class-methods-use-this, no-console */
const path = require('path');
const chalk = require('chalk');
const ms = require('ms');
const Logger = require('./helpers/Logger');
Expand All @@ -22,11 +23,9 @@ class TapReporter {
const {testResults, testFilePath} = suite;

if (testFilePath) {
const filePathParts = testFilePath.split('/');
const filePath = filePathParts.slice(0, filePathParts.length - 2).join('/');
const fileName = filePathParts[filePathParts.length - 1];
const {dir, base} = path.parse(testFilePath);

this.logger.info(`\n${chalk.grey('#')}${chalk.bgBlue(' SUITE ')} ${chalk.grey(`${filePath}/`)}${fileName}`);
this.logger.info(`\n${chalk.grey('#')}${chalk.bgBlue(' SUITE ')} ${chalk.grey(`${dir}${path.sep}`)}${base}`);
}

testResults.forEach((test) => {
Expand Down
2 changes: 1 addition & 1 deletion test/TapReporter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ test('TapReporter must output a Suite log with the Suites filePath if possible',

tapReporter.onTestResult({}, passingTestSuite);

expect(console.log.mock.calls[0][0]).toBe('\n# SUITE /Users/carlospastor/dev/mailonline/TapReporter.spec.js');
expect(console.log.mock.calls[0][0]).toBe('\n# SUITE /Users/carlospastor/dev/mailonline/jest-tap-reporter/TapReporter.spec.js');
tapReporter = new TapReporter();

console.log.mockClear();
Expand Down

0 comments on commit 592e310

Please sign in to comment.