Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

Added test + logic to shortcircuit test command #381

Merged
merged 4 commits into from
Mar 30, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cli/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
function test(command, argv) {
const logger = require('@blackbaud/skyux-logger');
const Server = require('karma').Server;
const path = require('path');
const glob = require('glob');
const tsLinter = require('./utils/ts-linter');
const configResolver = require('./utils/config-resolver');

Expand All @@ -17,6 +19,8 @@ function test(command, argv) {
const karmaConfigUtil = require('karma').config;
const karmaConfigPath = configResolver.resolve(command, argv);
const karmaConfig = karmaConfigUtil.parseConfig(karmaConfigPath);
const specsPath = path.resolve(process.cwd(), 'src/app/**/*.spec.ts');
const specsGlob = glob.sync(specsPath);

let lintResult;

Expand Down Expand Up @@ -46,6 +50,11 @@ function test(command, argv) {
process.exit(exitCode);
};

if (specsGlob.length === 0) {
logger.info('No spec files located. Stopping command from running.');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd maybe change the wording to "No spec files located. Skipping test command."

Copy link
Author

@Blackbaud-BobbyEarl Blackbaud-BobbyEarl Mar 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied this text verbatim from what's displayed today in skyux e2e. I'll update both to use your text, accounting for "test" vs "e2e" of course.

return onExit(0);
}

const server = new Server(karmaConfig, onExit);
server.on('run_start', onRunStart);
server.on('run_complete', onRunComplete);
Expand Down
12 changes: 12 additions & 0 deletions test/cli-test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,16 @@ describe('cli test', () => {

expect(process.exit).toHaveBeenCalledWith(0);
});

it('should not continue if no e2e spec files exist', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean "no unit test spec"?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Correcting now...

mock('glob', {
sync: path => []
});

mock.reRequire('../cli/test')('test');
expect(logger.info).toHaveBeenCalledWith(
'No spec files located. Stopping command from running.'
);
expect(process.exit).toHaveBeenCalledWith(0);
});
});