Skip to content

Commit

Permalink
Fix firestore VSCode scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jshcrowthe committed Oct 5, 2017
1 parent 3333ddc commit b519a5e
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 10 deletions.
31 changes: 24 additions & 7 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,41 @@
"type": "node",
"request": "launch",
"name": "Firestore Unit Tests (Node)",
"program": "${workspaceRoot}/node_modules/gulp/bin/gulp.js",
"args": ["test", "--suite=firestore/unit/", "--env=node"],
"port": 9229,
"program": "${workspaceRoot}/packages/firestore/node_modules/.bin/_mocha",
"cwd": "${workspaceRoot}/packages/firestore",
"args": [
"--compilers", "ts:ts-node/register",
"-r", "src/platform_node/node_init.ts",
"--retries", "5",
"--timeout", "5000",
"test/{,!(integration|browser)/**/}*.test.ts"
],
"sourceMaps": true,
"protocol": "inspector"
},
{
"type": "node",
"request": "launch",
"name": "Firestore Unit Tests (Browser)",
"program": "${workspaceRoot}/node_modules/gulp/bin/gulp.js",
"args": ["test", "--suite=firestore/unit/", "--env=browser", "--debug"]
"program": "${workspaceRoot}/packages/firestore/node_modules/.bin/karma",
"cwd": "${workspaceRoot}/packages/firestore",
"args": [
"start",
"--testFiles", "test/unit/bootstrap.ts",
"--browsers", "Chrome"
]
},
{
"type": "node",
"request": "launch",
"name": "Firestore Integration Tests (Browser)",
"program": "${workspaceRoot}/node_modules/gulp/bin/gulp.js",
"args": ["test", "--suite=firestore/integration", "--env=browser", "--debug"]
"program": "${workspaceRoot}/packages/firestore/node_modules/.bin/karma",
"cwd": "${workspaceRoot}/packages/firestore",
"args": [
"start",
"--testFiles", "test/integration/bootstrap.ts",
"--browsers", "Chrome"
]
}
]
}
12 changes: 11 additions & 1 deletion packages/firestore/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,21 @@
const karma = require('karma');
const path = require('path');
const karmaBase = require('../../config/karma.base');
const { argv } = require('yargs');

const testFiles = (files => {
if (!files) return;

This comment has been minimized.

Copy link
@wilhuff

wilhuff Oct 6, 2017

Contributor

This should probably return something:

if (!files) return [];

This comment has been minimized.

Copy link
@jshcrowthe

jshcrowthe Oct 6, 2017

Author Contributor

Intentionally using the falsy value to trip the ternary below

if (Array.isArray(files)) return files.map(file => ({ pattern: file }));
return [{ pattern: files }];
})(argv.testFiles);

module.exports = function(config) {
const karmaConfig = Object.assign({}, karmaBase, {
// files to load into karma
files: [{ pattern: `test/browser/bootstrap.ts` }],
files: testFiles ? testFiles : [
{ pattern: `test/unit/bootstrap.ts` },
{ pattern: `test/integration/bootstrap.ts` },
],
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha'],
Expand Down
3 changes: 2 additions & 1 deletion packages/firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"ts-loader": "^2.3.4",
"ts-node": "^3.3.0",
"typescript": "^2.4.2",
"webpack": "^3.5.5"
"webpack": "^3.5.5",
"yargs": "^9.0.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ import '../../src/platform_browser/browser_init';
* Taken from karma-webpack source:
* https://github.com/webpack-contrib/karma-webpack#alternative-usage
*/
var testsContext = (require as any).context('..', true, /.test$/);
var testsContext = (require as any).context('.', true, /.test$/);
testsContext.keys().forEach(testsContext);
26 changes: 26 additions & 0 deletions packages/firestore/test/unit/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import '../../src/platform_browser/browser_init';

/**
* This will include all of the test files and compile them as needed
*
* Taken from karma-webpack source:
* https://github.com/webpack-contrib/karma-webpack#alternative-usage
*/
var testsContext = (require as any).context('.', true, /.test$/);
testsContext.keys().forEach(testsContext);

0 comments on commit b519a5e

Please sign in to comment.