Tommy Martino | d770d7e | 2021-08-12 13:23:10 -0400 | [diff] [blame] | 1 | const playwright = require('playwright'); |
| 2 | // TODO: Re-enable when working on CI |
| 3 | // process.env.WEBKIT_HEADLESS_BIN = playwright.webkit.executablePath(); |
| 4 | process.env.FIREFOX_HEADLESS_BIN = playwright.firefox.executablePath(); |
| 5 | process.env.CHROMIUM_BIN = playwright.chromium.executablePath(); |
Tommy Martino | 76f06cb | 2020-07-30 19:50:54 -0400 | [diff] [blame] | 6 | |
| 7 | module.exports = function (config) { |
| 8 | config.set({ |
| 9 | // base path that will be used to resolve all patterns (eg. files, exclude) |
Tommy Martino | 22a0430 | 2020-09-28 16:40:49 -0400 | [diff] [blame] | 10 | basePath: '.', |
Tommy Martino | 76f06cb | 2020-07-30 19:50:54 -0400 | [diff] [blame] | 11 | |
| 12 | // frameworks to use |
| 13 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter |
| 14 | frameworks: ['jasmine'], |
| 15 | |
| 16 | // list of files / patterns to load in the browser |
| 17 | files: [ |
Tommy Martino | 22a0430 | 2020-09-28 16:40:49 -0400 | [diff] [blame] | 18 | { pattern: 'src/*.js', type: 'module' }, |
Tommy Martino | 76f06cb | 2020-07-30 19:50:54 -0400 | [diff] [blame] | 19 | { pattern: 'test/*.js', type: 'module' }, |
| 20 | 'test/*.html', |
| 21 | ], |
| 22 | |
| 23 | // list of files / patterns to exclude |
| 24 | exclude: [ |
Tommy Martino | 22a0430 | 2020-09-28 16:40:49 -0400 | [diff] [blame] | 25 | 'src/text-fragments.js', // so that the polyfill doesn't run in test |
Tommy Martino | 76f06cb | 2020-07-30 19:50:54 -0400 | [diff] [blame] | 26 | ], |
| 27 | |
| 28 | // preprocess matching files before serving them to the browser |
| 29 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor |
| 30 | preprocessors: { |
| 31 | '**/*.html': ['html2js'], |
| 32 | }, |
| 33 | |
| 34 | // test results reporter to use |
| 35 | // possible values: 'dots', 'progress' |
| 36 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter |
| 37 | reporters: ['progress'], |
| 38 | |
| 39 | // web server port |
| 40 | port: 9876, |
| 41 | |
| 42 | // enable / disable colors in the output (reporters and logs) |
| 43 | colors: true, |
| 44 | |
| 45 | // level of logging |
| 46 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG |
| 47 | logLevel: config.LOG_INFO, |
| 48 | |
| 49 | // enable / disable watching file and executing tests whenever any file changes |
| 50 | autoWatch: false, |
| 51 | |
| 52 | // start these browsers |
Tommy Martino | d770d7e | 2021-08-12 13:23:10 -0400 | [diff] [blame] | 53 | // TODO: WebkitHeadless would be great to add, but currently is causing issues on CI |
| 54 | browsers: ['ChromiumHeadlessNoSandbox', 'FirefoxHeadless'], |
Tommy Martino | 3953348 | 2020-10-08 12:14:28 -0400 | [diff] [blame] | 55 | customLaunchers: { |
Tommy Martino | d770d7e | 2021-08-12 13:23:10 -0400 | [diff] [blame] | 56 | ChromiumHeadlessNoSandbox: { |
| 57 | base: 'ChromiumHeadless', |
Tommy Martino | 3953348 | 2020-10-08 12:14:28 -0400 | [diff] [blame] | 58 | flags: ['--no-sandbox'] |
Ernesto Izquierdo | 986a382 | 2021-12-21 15:02:59 -0500 | [diff] [blame] | 59 | }, |
| 60 | Chrome_with_debugging: { |
| 61 | base: 'Chrome', |
| 62 | flags: ['--remote-debugging-port=9222'], |
| 63 | debug: true |
| 64 | }, |
| 65 | Firefox_with_debugging: { |
| 66 | base: 'Firefox', |
| 67 | flags: ['--remote-debugging-port=9222'], |
| 68 | debug: true |
Tommy Martino | 3953348 | 2020-10-08 12:14:28 -0400 | [diff] [blame] | 69 | } |
| 70 | }, |
Tommy Martino | 76f06cb | 2020-07-30 19:50:54 -0400 | [diff] [blame] | 71 | |
Tommy Martino | 44f9f2c | 2021-02-10 13:02:35 -0500 | [diff] [blame] | 72 | client: { |
| 73 | // We can't run in an iframe because some of the code under test is |
| 74 | // checking if it's inside an iframe. |
| 75 | useIframe: false, |
Ernesto Izquierdo | 986a382 | 2021-12-21 15:02:59 -0500 | [diff] [blame] | 76 | debug: config.debug |
Tommy Martino | 44f9f2c | 2021-02-10 13:02:35 -0500 | [diff] [blame] | 77 | }, |
| 78 | |
Tommy Martino | 76f06cb | 2020-07-30 19:50:54 -0400 | [diff] [blame] | 79 | // Continuous Integration mode |
| 80 | // if true, Karma captures browsers, runs the tests and exits |
| 81 | singleRun: false, |
| 82 | |
| 83 | // Concurrency level |
| 84 | // how many browser should be started simultaneous |
| 85 | concurrency: Infinity, |
| 86 | |
| 87 | html2JsPreprocessor: { |
| 88 | // strip this from the file path |
Tommy Martino | 6f91798 | 2020-08-04 10:19:38 -0400 | [diff] [blame] | 89 | stripPrefix: 'test/', |
Tommy Martino | 76f06cb | 2020-07-30 19:50:54 -0400 | [diff] [blame] | 90 | }, |
| 91 | }); |
| 92 | }; |