Skip to content

Update @firebase/template to move tests next to source files #2875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 5 additions & 2 deletions config/karma.base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright 2017 Google Inc.
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -57,7 +57,10 @@ const config = {
// preprocess matching files before serving them to the browser
// available preprocessors:
// https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: { 'test/**/*.ts': ['webpack', 'sourcemap'] },
preprocessors: {
'test/**/*.ts': ['webpack', 'sourcemap'],
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we get rid of this pattern since template doesn't have a test/ dir anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

This config file is shared with packages that still have tests in the test/ dir, so we need to keep it for now.

'src/**/*.test.ts': ['webpack', 'sourcemap']
},

mime: { 'text/x-typescript': ['ts', 'tsx'] },

Expand Down
3 changes: 1 addition & 2 deletions packages/installations/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright 2019 Google Inc.
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,6 @@ module.exports = function(config) {
config.set({
...karmaBase,
files,
preprocessors: { '**/*.ts': ['webpack', 'sourcemap'] },
frameworks: ['mocha']
});
};
Expand Down
11 changes: 4 additions & 7 deletions packages/messaging/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright 2017 Google Inc.
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,21 +15,18 @@
* limitations under the License.
*/

const karma = require('karma');
const path = require('path');
const karmaBase = require('../../config/karma.base');

const FILES = [`src/**/*.test.ts`];
const files = [`src/**/*.test.ts`];

module.exports = function(config) {
const karmaConfig = {
...karmaBase,
files: FILES,
preprocessors: { 'src/**/*.test.ts': ['webpack', 'sourcemap'] },
files,
frameworks: ['mocha']
};

config.set(karmaConfig);
};

module.exports.files = FILES;
module.exports.files = files;
11 changes: 6 additions & 5 deletions packages/template/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright 2019 Google Inc.
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,16 +17,17 @@

const karmaBase = require('../../config/karma.base');

const files = [`test/**/*`];
const files = [`src/**/*.test.ts`];

module.exports = function(config) {
const karmaConfig = Object.assign({}, karmaBase, {
const karmaConfig = {
...karmaBase,
// files to load into karma
files: files,
files,
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha']
});
};

config.set(karmaConfig);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dev": "rollup -c -w",
"test": "yarn type-check && run-p lint test:browser test:node",
"test:browser": "karma start --single-run",
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha test/**/*.test.* --opts ../../config/mocha.node.opts",
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.* --opts ../../config/mocha.node.opts",
"type-check": "tsc -p . --noEmit",
"prepare": "yarn build"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright 2017 Google Inc.
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@
*/

import { expect } from 'chai';
import { testFxn } from '../src';
import { testFxn } from './index';

describe('Simple test', () => {
it('Should skip this test');
Expand Down