Skip to content

Commit

Permalink
ignore PREPEND_DIR while updating test files (#138)
Browse files Browse the repository at this point in the history
* ignore PREPEND_DIR while updating test files

* fix prepend dir usage

* add comment; fix undefined error

* typo fix

* remove prependDir from opts
  • Loading branch information
olexandr13 authored Dec 9, 2023
1 parent aea733b commit 4bbef2c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,11 @@ class Analyzer {
}

// append file name to each test
let fileName = path.relative(this.workDir, file);
if (process.env.TESTOMATIO_PREPEND_DIR) {
fileName = path.join(process.env.TESTOMATIO_PREPEND_DIR, fileName);
}
const fileName = path.relative(this.workDir, file);
// prepend dir should not affect the actual file path, it is used only on Testomatio side
// if (process.env.TESTOMATIO_PREPEND_DIR) {
// fileName = path.join(process.env.TESTOMATIO_PREPEND_DIR, fileName);
// }

/**
* Assigns the array of TestData objects to the `tests` variable.
Expand Down
5 changes: 4 additions & 1 deletion src/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const URL = process.env.TESTOMATIO_URL || 'https://app.testomat.io';
const isHttps = URL.startsWith('https');
const debug = require('debug')('testomatio:ids');
const { request } = isHttps ? require('https') : require('http');
const path = require('path');

class Reporter {
constructor(apiKey, framework) {
Expand Down Expand Up @@ -59,9 +60,11 @@ class Reporter {
return new Promise((resolve, reject) => {
console.log('\n 🚀 Sending data to testomat.io\n');

// unify path to use slashes (prevent backslashes on windows)
const tests = this.tests.map(test => {
// unify path to use slashes (prevent backslashes on windows)
test.file = test.file?.replace(/\\/g, '/');
// add prepend dir to path
test.file = path.join(process.env.TESTOMATIO_PREPEND_DIR || '', test.file);
return test;
});
this.tests = tests;
Expand Down
2 changes: 1 addition & 1 deletion tests/analyzer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('analyzer', () => {
const tests = analyzer.getDecorator().tests;
expect(tests[0].file)
.to.be.a('string')
.and.satisfy(msg => msg.startsWith('MyTests/'));
.and.satisfy(msg => msg.startsWith(''));
});
});
});

0 comments on commit 4bbef2c

Please sign in to comment.