diff --git a/index.js b/index.js new file mode 100644 index 0000000..0ac3c47 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +module.exports = { + local: require('./wdio.local.conf'), +}; diff --git a/package.json b/package.json index 4bb237f..6557a7f 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "description": "End-2-End test suite for InstantSearch", "homepage": "https://github.com/algolia/instantsearch-e2e-tests", + "main": "./index.js", "keywords": [ "algolia", "instantsearch", @@ -20,6 +21,7 @@ "type-check:watch": "yarn type-check --watch" }, "dependencies": { + "ts-node": "^8.3.0", "typescript": "^3.5.3" }, "devDependencies": { @@ -35,5 +37,14 @@ "eslint-plugin-wdio": "5.11.0", "prettier": "1.18.2", "webdriverio": "5.11.13" + }, + "peerDependencies": { + "@wdio/cli": "^5.11.13", + "@wdio/jasmine-framework": "^5.11.0", + "@wdio/local-runner": "^5.11.13", + "@wdio/sauce-service": "^5.11.1", + "@wdio/selenium-standalone-service": "^5.11.2", + "@wdio/spec-reporter": "^5.11.7", + "@wdio/static-server-service": "^5.11.0" } } diff --git a/wdio.base.conf.js b/wdio.base.conf.js new file mode 100644 index 0000000..8c735f7 --- /dev/null +++ b/wdio.base.conf.js @@ -0,0 +1,85 @@ +const path = require('path'); + +module.exports = { + /* + * Use the Static Server Service to start serve demos to run our tests against + * https://webdriver.io/docs/static-server-service.html + * https://github.com/webdriverio/webdriverio/tree/master/packages/wdio-static-server-service + */ + services: ['static-server'], + staticServerFolders: [{ mount: '/', path: './website' }], + staticServerPort: 5000, + /* + * Set the static server, started above, as the base URL + * Will be prepended to the `url` parameter of `browser.url()` calls + * https://webdriver.io/docs/configurationfile.html + * https://webdriver.io/docs/api/browser/url.html + */ + baseUrl: 'http://localhost:5000', + + /* + * Specify Test Files + * Using absolute path to run test files from the package root + * instead of the directory from which `wdio` was called + * https://webdriver.io/docs/configurationfile.html + */ + specs: [path.join(__dirname, 'specs/**/*.spec.ts')], + + /* + * Level of logging verbosity + * Can be: trace, debug, info, warn, error, silent + * https://webdriver.io/docs/options.html#loglevel + */ + logLevel: 'warn', + /* + * Default timeout for all waitForXXX commands + * https://webdriver.io/docs/options.html#waitfortimeout + */ + waitforTimeout: 10000, + /* + * Stop tests on first fail + * https://webdriver.io/docs/options.html#bail + */ + bail: 1, + + /* + * Uses Jasmine as test framework + * Since Jest is not supported by WebdriverIO yet we choose to use the Jasmine framework as it has a very close syntax + * https://webdriver.io/docs/options.html#framework + * https://github.com/webdriverio/webdriverio/tree/master/packages/wdio-jasmine-framework + */ + framework: 'jasmine', + /* + * Specific Jasmine related options + * https://webdriver.io/docs/options.html#mochaopts-jasminenodeopts + * https://github.com/webdriverio/webdriverio/tree/master/packages/wdio-jasmine-framework#configuration + */ + jasmineNodeOpts: { + defaultTimeoutInterval: 60000, + }, + /* + * List of reporters to use + * https://webdriver.io/docs/options.html#reporters + * https://github.com/webdriverio/webdriverio/tree/master/packages/wdio-spec-reporter + */ + reporters: ['spec'], + + /* + * Hooks + * https://webdriver.io/docs/options.html#hooks + */ + + /* + * `before` hook (executed before test execution begins) registering TypeScript to compile our `.ts` files + * https://webdriver.io/docs/typescript.html + */ + before() { + require('ts-node').register({ + files: true, + transpileOnly: true, + // Force `ts-node` to use the config file from the package root + // instead of the directory from which `wdio` was called + project: path.join(__dirname, './tsconfig.json'), + }); + }, +}; diff --git a/wdio.local.conf.js b/wdio.local.conf.js new file mode 100644 index 0000000..f5a19e4 --- /dev/null +++ b/wdio.local.conf.js @@ -0,0 +1,21 @@ +const baseConfig = require('./wdio.base.conf'); + +module.exports = { + ...baseConfig, + /* + * Start a Selenium Standalone Service to run our tests on our local machine + * https://webdriver.io/docs/selenium-standalone-service.html + * https://github.com/webdriverio/webdriverio/tree/master/packages/wdio-selenium-standalone-service + */ + services: [...(baseConfig.services || []), 'selenium-standalone'], + /* + * Platforms where we want to run our tests + * Since it will be run on the local machine and we don't know any of its capacity + * then we stay very vague and only target the most common browser + */ + capabilities: [ + { + browserName: 'chrome', + }, + ], +}; diff --git a/yarn.lock b/yarn.lock index 6aa7e4b..8ade8f4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -173,6 +173,11 @@ archiver@^3.0.0: tar-stream "^2.1.0" zip-stream "^2.1.2" +arg@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.1.tgz#485f8e7c390ce4c5f78257dbea80d4be11feda4c" + integrity sha512-SlmP3fEA88MBv0PypnXZ8ZfJhwmDeIE3SP71j37AiXQBXYosPV0x6uISAaHYSlSVhmHOVkomen0tbGk6Anlebw== + argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" @@ -264,6 +269,11 @@ buffer-crc32@^0.2.1, buffer-crc32@^0.2.13: resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" integrity sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI= +buffer-from@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" + integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== + buffer@^5.1.0: version "5.2.1" resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.2.1.tgz#dd57fa0f109ac59c602479044dca7b8b3d0b71d6" @@ -426,6 +436,11 @@ delayed-stream@~1.0.0: resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= +diff@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.1.tgz#0c667cb467ebbb5cea7f14f135cc2dba7780a8ff" + integrity sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q== + doctrine@1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa" @@ -1151,6 +1166,11 @@ lru-cache@^5.1.1: dependencies: yallist "^3.0.2" +make-error@^1.1.1: + version "1.3.5" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8" + integrity sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g== + mime-db@1.40.0: version "1.40.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.40.0.tgz#a65057e998db090f732a68f6c276d387d4126c32" @@ -1588,6 +1608,19 @@ slice-ansi@^2.1.0: astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" +source-map-support@^0.5.6: + version "0.5.13" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.13.tgz#31b24a9c2e73c2de85066c0feb7d44767ed52932" + integrity sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + spdx-correct@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.0.tgz#fb83e504445268f154b074e218c87c003cd31df4" @@ -1742,6 +1775,17 @@ tough-cookie@~2.4.3: psl "^1.1.24" punycode "^1.4.1" +ts-node@^8.3.0: + version "8.3.0" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.3.0.tgz#e4059618411371924a1fb5f3b125915f324efb57" + integrity sha512-dyNS/RqyVTDcmNM4NIBAeDMpsAdaQ+ojdf0GOLqE6nwJOgzEkdRNzJywhDfwnuvB10oa6NLVG1rUJQCpRN7qoQ== + dependencies: + arg "^4.1.0" + diff "^4.0.1" + make-error "^1.1.1" + source-map-support "^0.5.6" + yn "^3.0.0" + tslib@^1.8.1, tslib@^1.9.0: version "1.10.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" @@ -1882,6 +1926,11 @@ yallist@^3.0.2: resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9" integrity sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A== +yn@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== + zip-stream@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/zip-stream/-/zip-stream-2.1.2.tgz#841efd23214b602ff49c497cba1a85d8b5fbc39c"