Files
meteor/tools/isobuild/test-files.js
James Burgess 2547957268 Fix meteor test file matching patterns (#9339)
* Adjust test filename RegExps to match Meteor guide. Fixes #9332.
* Adjusted help text for --drive-package on meteor test.
* Add integration tests for `meteor test` eager file loading.
* Fix typo in selftest.forbid comment.
* Improve test file eager load integration test coverage and clarity.
2017-11-22 11:21:49 -05:00

31 lines
789 B
JavaScript

import _ from 'underscore';
import { pathSep } from '../fs/files';
// We have two things "tests" and "app-tests".
export const TEST_FILENAME_REGEXPS = [
// "*.test[s].*" or "*.spec[s].*"
/\.test\./,
/\.tests\./,
/\.spec\./,
/\.specs\./,
];
export const APP_TEST_FILENAME_REGEXPS = [
// "*.app-test[s].*" or "*.app-spec[s].*"
/\.app-test\./,
/\.app-tests\./,
/\.app-spec\./,
/\.app-specs\./,
];
// Given a path to a file in an app (relative to the app root
// directory), is this file a test file?
export function isTestFilePath(path) {
const splitPath = path.split(pathSep);
// Does the filename match one of the test filename forms?
return _.any(
[...TEST_FILENAME_REGEXPS, ...APP_TEST_FILENAME_REGEXPS],
regexp => regexp.test(_.last(splitPath)));
}