Add a separate tsconfig for tests

Tests run with nodejs + jest types, while the web extension code
runs with browser + web-ext type roots.
This commit is contained in:
Jakub Okoński 2019-10-18 13:05:37 +02:00
parent bd2b988338
commit 67fa18b4ec
7 changed files with 54 additions and 23 deletions

View file

@ -20,6 +20,7 @@
"@types/jest": "^24.0.19", "@types/jest": "^24.0.19",
"@types/mithril": "^2.0.0", "@types/mithril": "^2.0.0",
"@types/node": "^12.11.1", "@types/node": "^12.11.1",
"@types/selenium-webdriver": "^4.0.5",
"awesome-typescript-loader": "^5.2.1", "awesome-typescript-loader": "^5.2.1",
"cleanslate": "^0.10.1", "cleanslate": "^0.10.1",
"copy-webpack-plugin": "^5.0.4", "copy-webpack-plugin": "^5.0.4",
@ -58,9 +59,7 @@
"pretty": "bash scripts/pretty.sh" "pretty": "bash scripts/pretty.sh"
}, },
"jest": { "jest": {
"transform": { "preset": "ts-jest",
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [ "moduleFileExtensions": [
"ts", "ts",
@ -74,6 +73,7 @@
}, },
"globals": { "globals": {
"ts-jest": { "ts-jest": {
"tsConfig": "tsconfig.test.json",
"diagnostics": { "diagnostics": {
"ignoreCodes": [ "ignoreCodes": [
151001 151001

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
dest=generated/static/docs dest=generated/static/docs
"$(yarn bin)/typedoc" --theme src/static/typedoc/ --out $dest src --ignoreCompilerErrors "$(yarn bin)/typedoc" --theme src/static/typedoc/ --exclude "src/**/?(test_utils|*.test).ts" --out $dest src --ignoreCompilerErrors
cp -r $dest build/static/ cp -r $dest build/static/

View file

@ -861,7 +861,7 @@ let JUMPED: boolean
/** @hidden */ /** @hidden */
//#content_helper //#content_helper
let JUMP_TIMEOUTID let JUMP_TIMEOUTID: number | undefined
/** This is used as an ID for the current page in the jumplist. /** This is used as an ID for the current page in the jumplist.
It has a potentially confusing behavior: if you visit site A, then site B, then visit site A again, the jumplist that was created for your first visit on A will be re-used for your second visit. It has a potentially confusing behavior: if you visit site A, then site B, then visit site A again, the jumplist that was created for your first visit on A will be re-used for your second visit.

View file

@ -1,12 +1,11 @@
require("geckodriver") import "geckodriver"
const fs = require("fs") import * as fs from "fs"
const os = require("os") import * as os from "os"
const path = require("path") import * as path from "path"
const webdriver = require("selenium-webdriver") import * as webdriver from "selenium-webdriver"
const Until = webdriver.until const {until, By} = webdriver
const By = webdriver.By import {Options} from "selenium-webdriver/firefox"
const Options = require("selenium-webdriver/firefox").Options
jest.setTimeout(100000) jest.setTimeout(100000)
@ -92,7 +91,7 @@ function sendKeys (driver, keys) {
describe("webdriver", () => { describe("webdriver", () => {
function iframeLoaded(driver) { function iframeLoaded(driver) {
return driver.wait(Until.elementLocated(By.id("cmdline_iframe"))) return driver.wait(until.elementLocated(By.id("cmdline_iframe")))
} }
async function getDriver() { async function getDriver() {
@ -199,8 +198,8 @@ describe("webdriver", () => {
// Then, make sure rsscmd is executed and has the right arguments // Then, make sure rsscmd is executed and has the right arguments
await sendKeys(driver, "<Tab><CR>") await sendKeys(driver, "<Tab><CR>")
await driver.switchTo().parentFrame() await (driver.switchTo() as any).parentFrame()
const elem = await driver.wait(Until.elementLocated(By.id("rsscmdExecuted"))) const elem = await driver.wait(until.elementLocated(By.id("rsscmdExecuted")))
expect(url).toMatch(await elem.getAttribute("innerText")) expect(url).toMatch(await elem.getAttribute("innerText"))
} catch (e) { } catch (e) {
fail(e) fail(e)

View file

@ -7,7 +7,7 @@
"sourceMap": true, "sourceMap": true,
"target": "es2017", "target": "es2017",
"lib": ["es2017","es2019.array","dom", "dom.iterable"], "lib": ["es2017","es2019.array","dom", "dom.iterable"],
"typeRoots": ["node_modules/@types", "node_modules/web-ext-types/"], "types": ["web-ext-types"],
"experimentalDecorators": true, "experimentalDecorators": true,
"alwaysStrict": true, "alwaysStrict": true,
"baseUrl": "src/", "baseUrl": "src/",
@ -19,6 +19,7 @@
"./src/**/*" "./src/**/*"
], ],
"exclude": [ "exclude": [
"./src/**/*.test.ts" "./src/**/*.test.ts",
"./src/lib/test_utils.ts"
] ]
} }

26
tsconfig.test.json Normal file
View file

@ -0,0 +1,26 @@
{
"compilerOptions": {
"allowJs": true,
"moduleResolution": "node",
"noImplicitAny": false,
"noEmitOnError": true,
"outDir": "build/tsc-out",
"sourceMap": true,
"target": "es2017",
"lib": ["es2017", "es2019.array", "es2018.promise", "dom", "dom.iterable"],
"typeRoots": ["node_modules/@types"],
"types": ["jest", "node"],
"experimentalDecorators": true,
"alwaysStrict": true,
"baseUrl": "src/",
"paths": {
"@src/*": ["*"]
}
},
"include": [
"./src/**/*"
],
"exclude": [
"./src/**/*.test.ts"
]
}

View file

@ -453,6 +453,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.11.1.tgz#1fd7b821f798b7fa29f667a1be8f3442bb8922a3" resolved "https://registry.yarnpkg.com/@types/node/-/node-12.11.1.tgz#1fd7b821f798b7fa29f667a1be8f3442bb8922a3"
integrity sha512-TJtwsqZ39pqcljJpajeoofYRfeZ7/I/OMUQ5pR4q5wOKf2ocrUvBAZUMhWsOvKx3dVc/aaV5GluBivt0sWqA5A== integrity sha512-TJtwsqZ39pqcljJpajeoofYRfeZ7/I/OMUQ5pR4q5wOKf2ocrUvBAZUMhWsOvKx3dVc/aaV5GluBivt0sWqA5A==
"@types/selenium-webdriver@^4.0.5":
version "4.0.5"
resolved "https://registry.yarnpkg.com/@types/selenium-webdriver/-/selenium-webdriver-4.0.5.tgz#23041a4948c82daf2df9836e4d2358fec10d3e24"
integrity sha512-ma1aL1znI3ptEbSQgbywgadrRCJouPIACSfOl/bPwu/TPNSyyE/+o9jZ6+bpDVTtIdksZuVKpq4SR1ip3DRduw==
"@types/stack-utils@^1.0.1": "@types/stack-utils@^1.0.1":
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e"