|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright 2020 Google LLC. All Rights Reserved. |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * ============================================================================= |
| 16 | + */ |
| 17 | + |
| 18 | +const karmaTypescriptConfig = { |
| 19 | + tsconfig: 'tsconfig.json', |
| 20 | + // Disable coverage reports and instrumentation by default for tests |
| 21 | + coverageOptions: {instrumentation: false}, |
| 22 | + reports: {}, |
| 23 | + bundlerOptions: { |
| 24 | + sourceMap: true, |
| 25 | + // Ignore the import of the `worker_threads` package used in a core test |
| 26 | + // meant to run in node. |
| 27 | + exclude: ['worker_threads'], |
| 28 | + // worker_node_test in tfjs-core contains a conditional require statement |
| 29 | + // that confuses the bundler of karma-typescript. |
| 30 | + ignore: ['./worker_node_test'] |
| 31 | + } |
| 32 | +}; |
| 33 | + |
| 34 | +module.exports = function(config) { |
| 35 | + const args = []; |
| 36 | + if (config.grep) { |
| 37 | + args.push('--grep', config.grep); |
| 38 | + } |
| 39 | + if (config.flags) { |
| 40 | + args.push('--flags', config.flags); |
| 41 | + } |
| 42 | + let exclude = []; |
| 43 | + if (config.excludeTest != null) { |
| 44 | + exclude.push(config.excludeTest); |
| 45 | + } |
| 46 | + |
| 47 | + config.set({ |
| 48 | + frameworks: ['jasmine', 'karma-typescript'], |
| 49 | + files: [ |
| 50 | + 'src/setup_test.ts', |
| 51 | + {pattern: 'src/**/*.ts'}, |
| 52 | + ], |
| 53 | + preprocessors: {'**/*.ts': ['karma-typescript']}, |
| 54 | + karmaTypescriptConfig, |
| 55 | + reporters: ['dots', 'karma-typescript'], |
| 56 | + exclude, |
| 57 | + colors: true, |
| 58 | + autoWatch: false, |
| 59 | + browsers: ['Chrome'], |
| 60 | + singleRun: true, |
| 61 | + client: {jasmine: {random: false}, args: args}, |
| 62 | + browserStack: { |
| 63 | + username: process.env.BROWSERSTACK_USERNAME, |
| 64 | + accessKey: process.env.BROWSERSTACK_KEY |
| 65 | + }, |
| 66 | + captureTimeout: 120000, |
| 67 | + reportSlowerThan: 500, |
| 68 | + browserNoActivityTimeout: 240000, |
| 69 | + customLaunchers: { |
| 70 | + // For browserstack configs see: |
| 71 | + // https://www.browserstack.com/automate/node |
| 72 | + bs_chrome_mac: { |
| 73 | + base: 'BrowserStack', |
| 74 | + browser: 'chrome', |
| 75 | + browser_version: 'latest', |
| 76 | + os: 'OS X', |
| 77 | + os_version: 'High Sierra' |
| 78 | + }, |
| 79 | + bs_firefox_mac: { |
| 80 | + base: 'BrowserStack', |
| 81 | + browser: 'firefox', |
| 82 | + browser_version: 'latest', |
| 83 | + os: 'OS X', |
| 84 | + os_version: 'High Sierra' |
| 85 | + }, |
| 86 | + bs_safari_mac: { |
| 87 | + base: 'BrowserStack', |
| 88 | + browser: 'safari', |
| 89 | + browser_version: 'latest', |
| 90 | + os: 'OS X', |
| 91 | + os_version: 'High Sierra' |
| 92 | + }, |
| 93 | + bs_ios_11: { |
| 94 | + base: 'BrowserStack', |
| 95 | + device: 'iPhone X', |
| 96 | + os: 'iOS', |
| 97 | + os_version: '11.0', |
| 98 | + real_mobile: true |
| 99 | + }, |
| 100 | + bs_android_9: { |
| 101 | + base: 'BrowserStack', |
| 102 | + device: 'Google Pixel 3 XL', |
| 103 | + os: 'android', |
| 104 | + os_version: '9.0', |
| 105 | + real_mobile: true |
| 106 | + }, |
| 107 | + win_10_chrome: { |
| 108 | + base: 'BrowserStack', |
| 109 | + browser: 'chrome', |
| 110 | + // Latest Chrome on Windows has WebGL problems: |
| 111 | + // https://github.com/tensorflow/tfjs/issues/2272 |
| 112 | + browser_version: '77.0', |
| 113 | + os: 'Windows', |
| 114 | + os_version: '10' |
| 115 | + }, |
| 116 | + }, |
| 117 | + }) |
| 118 | +} |
0 commit comments