Skip to content

Commit

Permalink
Allow specific paths to be passed to js-api-spec (#1917)
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 authored Jun 6, 2023
1 parent 42c843f commit c856cad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
19 changes: 17 additions & 2 deletions js-api-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,25 @@ process.on('exit', () => {
tmpObject.removeCallback();
});

const specsToRun =
argv._.length > 0
? argv._.map(arg => arg.toString()).map(path =>
path.endsWith('.test.ts') ? path : '$path/**/*.test.ts'
)
: ['js-api-spec/**/*.test.ts'];

if (argv.browser) {
const karmaConfig = config.parseConfig(
p.resolve(__dirname, 'karma.config.js'),
{port: 9876},
{
port: 9876,
files: [
'js-api-spec/setup.ts',
...specsToRun.map(path =>
path.replace('*.test.ts', '!(*.node).test.ts')
),
],
},
{throwErrors: true}
);
const server = new Server(karmaConfig, exitCode => {
Expand All @@ -120,7 +135,7 @@ if (argv.browser) {
jasmine.env.addReporter(new SpecReporter());
jasmine.loadConfig({
spec_dir: 'js-api-spec',
spec_files: ['**/*.test.ts'],
spec_files: specsToRun.map(path => p.relative('js-api-spec', path)),
helpers: ['../node_modules/jasmine-expect/index.js', 'setup.ts'],
});
jasmine.execute();
Expand Down
3 changes: 0 additions & 3 deletions karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ module.exports = config => {
// available frameworks: https://www.npmjs.com/search?q=keywords:karma-adapter
frameworks: ['jasmine', 'jasmine-matchers'],

// list of files / patterns to load in the browser
files: ['js-api-spec/setup.ts', 'js-api-spec/**/!(*.node).test.ts'],

// list of files / patterns to exclude
exclude: [],

Expand Down

0 comments on commit c856cad

Please sign in to comment.