Skip to content

Commit

Permalink
feat: add smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
umpox committed Mar 21, 2022
1 parent 27a56fd commit 5905b75
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 42 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
module.exports = {
extends: ['@sourcegraph/eslint-config'],
env: {
node: true,
es6: true,
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
project: ['./packages/**/tsconfig.json'],
tsconfigRootDir: __dirname,
warnOnUnsupportedTypeScriptVersion: false,
},
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ node_modules
npm-debug.log
yarn-error.log
.eslintcache
*.tsbuildinfo
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"editor.formatOnSave": true,
"eslint.validate": ["javascript"],
"typescript.format.semicolons": "remove",
"eslint.validate": ["javascript", "typescript"],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
},
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"packages/*"
],
"dependencies": {
"@commitlint/cli": "^14.1.0",
"@commitlint/config-conventional": "^14.1.0",
"@sourcegraph/eslint-config": "^0.27.0",
"@sourcegraph/prettierrc": "^3.0.3",
"eslint": "^7.32.0",
"prettier": "^2.6.0",
"@commitlint/cli": "^14.1.0",
"@commitlint/config-conventional": "^14.1.0",
"husky": "^4.3.5",
"prettier": "^2.6.0",
"semantic-release": "^17.1.2"
},
"commitlint": {
Expand Down
4 changes: 3 additions & 1 deletion packages/web-functionality/.eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
out/
lib
jest.config.js
jest-puppeteer.config.js
3 changes: 0 additions & 3 deletions packages/web-functionality/.eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/web-functionality/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"scripts": {
"test": "yarn build && SOURCEGRAPH_URL=https://sourcegraph.com HEADLESS=false ./lib/src/index.js",
"eslint": "eslint --cache 'src/*.[jt]s?(x)'",
"eslint": "eslint '**/*.[tj]s'",
"prettier-check": "prettier --check .",
"semantic-release": "semantic-release",
"build": "tsc"
Expand Down
25 changes: 11 additions & 14 deletions packages/web-functionality/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,24 @@ if (!SOURCEGRAPH_URL) {
throw new Error('SOURCEGRAPH_URL was not set. Please provide a valid URL to run the smoke tests against.')
}

const handler = async () => {
/**
* Note: There is no officially supported way to run Jest programmatically.
* We avoid using the unstable `jest.run()` API.
* https://github.com/facebook/jest/issues/5048
*/
const start = async () => {
const handler = async (): Promise<void> => {
try {
/**
* Note: There is no officially supported way to run Jest programmatically.
* We avoid using the unstable `jest.run()` API.
* https://github.com/facebook/jest/issues/5048
*/
await execa('jest', ['--runInBand'], {
cwd: __dirname,
shell: true,
stdio: 'inherit',
env: { SOURCEGRAPH_URL },
})
}

try {
await start()
} catch (e) {
console.error(e)
process.exit(e.exitCode || 1)
} catch (error) {
console.error(error)
process.exit(error?.exitCode || 1)
}
}

// eslint-disable-next-line @typescript-eslint/no-floating-promises
handler()
File renamed without changes.
20 changes: 2 additions & 18 deletions packages/web-functionality/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
{
"extends": "@sourcegraph/tsconfig",
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"allowJs": false,
"moduleResolution": "node",
"esModuleInterop": true,
"lib": ["esnext"],
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"noErrorTruncation": true,
"importHelpers": true,
"resolveJsonModule": true,
"composite": true,
"outDir": "lib",
"rootDir": ".",
},

"exclude": ["lib", "node_modules"],
"include": ["src"],
}
1 change: 0 additions & 1 deletion packages/web-functionality/tsconfig.tsbuildinfo

This file was deleted.

20 changes: 20 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "@sourcegraph/tsconfig",
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"allowJs": false,
"moduleResolution": "node",
"esModuleInterop": true,
"lib": ["esnext"],
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"noErrorTruncation": true,
"importHelpers": true,
"resolveJsonModule": true,
"composite": true,
},
}

0 comments on commit 5905b75

Please sign in to comment.