From bf3073b00ece8384d1c41f5ed7dfb3e6974e39f4 Mon Sep 17 00:00:00 2001 From: Trevor McKeown Date: Mon, 15 Jan 2024 11:37:43 -0500 Subject: [PATCH] test: relative directories for tmpDir and reportsDir test: absolute directories for tmpDir and reportsDir --- test/parse-args.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test/parse-args.js b/test/parse-args.js index 004c7241..fa2d5267 100644 --- a/test/parse-args.js +++ b/test/parse-args.js @@ -6,7 +6,7 @@ const { hideInstrumenterArgs } = require('../lib/parse-args') -const { join } = require('path') +const { join, resolve } = require('path') describe('parse-args', () => { describe('hideInstrumenteeArgs', () => { @@ -63,6 +63,28 @@ describe('parse-args', () => { argv.lines.should.be.equal(100) argv.functions.should.be.equal(24) }) + it('should allow relative path reports directories', () => { + const argsArray = ['node', 'c8', '--lines', '100', '--reports-dir', './coverage_'] + const argv = buildYargs().parse(argsArray) + argv.reportsDir.should.be.equal('./coverage_') + }) + it('should allow relative path temporary directories', () => { + const argsArray = ['node', 'c8', '--lines', '100', '--temp-directory', './coverage/tmp_'] + const argv = buildYargs().parse(argsArray) + argv.tempDirectory.should.be.equal('./coverage/tmp_') + }) + it('should allow absolute path reports directories', () => { + const tmpDir = resolve(process.cwd(), 'coverage_') + const argsArray = ['node', 'c8', '--lines', '100', '--reports-dir', tmpDir] + const argv = buildYargs().parse(argsArray) + argv.reportsDir.should.be.equal(tmpDir) + }) + it('should allow absolute path temporary directories', () => { + const tmpDir = resolve(process.cwd(), './coverage/tmp_') + const argsArray = ['node', 'c8', '--lines', '100', '--temp-directory', tmpDir] + const argv = buildYargs().parse(argsArray) + argv.tempDirectory.should.be.equal(tmpDir) + }) }) describe('--merge-async', () => {