Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add tsconfig and build for e2e #627

Draft
wants to merge 1 commit into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ server/node_modules/**
server/out/**
client/.eslintrc.js
server/.eslintrc.js
test/e2e/projects/**
.eslintrc.js
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
"url": "https://github.com/NomicFoundation/hardhat-vscode/issues"
},
"scripts": {
"build": "tsc -b ./client/tsconfig.json && tsc -b ./server/tsconfig.build.json && tsc -b ./coc/tsconfig.json && tsc -b",
"build": "tsc -b ./client/tsconfig.json && tsc -b ./server/tsconfig.build.json && tsc -b ./coc/tsconfig.json",
"watch": "concurrently -n client,server \"tsc -b -w ./client/tsconfig.json\" \"tsc -b -w ./server/tsconfig.build.json\"",
"test:unit": "npm -w server run test",
"test:protocol": "npm -w test/protocol run test",
"test:e2e": "npm run build && node ./out/test/runTests.js",
"test:e2e": "npm -w test/e2e run test",
"test": "npm run test:unit && npm run test:protocol && npm run test:e2e",
"test:coverage": "npm -w server run test:coverage",
"test:codecov": "npm -w server run test:codecov",
Expand Down
21 changes: 21 additions & 0 deletions test/e2e/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
extends: [`../../.eslintrc.js`],
parserOptions: {
project: `${__dirname}/tsconfig.json`,
sourceType: "module",
},
overrides: [
{
files: ["**/*.ts"],
rules: {
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-empty-function": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"no-empty": "warn",
},
},
],
};
1 change: 1 addition & 0 deletions test/e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
out
111 changes: 0 additions & 111 deletions test/e2e/client.ts

This file was deleted.

5 changes: 4 additions & 1 deletion test/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"version": "1.0.0",
"private": true,
"scripts": {
"postinstall": "cd ./projects/main && npm install"
"postinstall": "cd ./projects/main && npm install",
"pretest": "tsc -b ./tsconfig.json",
"test": "node ./out/runTests.js",
"clean": "rimraf out .nyc_output coverage *.tsbuildinfo"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 11 additions & 4 deletions test/runTests.ts → test/e2e/src/runTests.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import * as path from "path";
import { runTests } from "@vscode/test-electron";

(async () => {
const main = async () => {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(
__dirname,
"..",
"..",
"..",
"client"
);

// The path to test runner
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, "e2e", "index");
const extensionTestsPath = path.resolve(__dirname, "index");

const folder = path.resolve(__dirname, "..", "..", "test", "e2e");
const folder = path.resolve(__dirname, "..", "..", "e2e");

// Download VS Code, unzip it and run the e2e test
await runTests({
Expand All @@ -39,4 +40,10 @@ import { runTests } from "@vscode/test-electron";
console.error("Failed to run tests, err:", err);
process.exitCode = 1;
}
})();
};

main().catch((err) => {
// eslint-disable-next-line no-console
console.error("Failed to run tests, err:", err);
process.exitCode = 1;
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,28 @@ suite("task - clean", function () {

// Create an artifacts folder to be cleaned up
const artifactsPath = path.join(getRootPath(), "projects/main/artifacts");

if (!existsSync(artifactsPath)) {
mkdirSync(artifactsPath);
}

assert.ok(existsSync(artifactsPath));

// Run clean task
await vscode.commands.executeCommand("workbench.action.tasks.runTask", {
type: "hardhat",
task: "clean",
});

await waitForUI();

// Wait for the task to finish
await new Promise((resolve) => vscode.tasks.onDidEndTask(resolve));

// Assert the artifacts were removed
assert.ok(!existsSync(artifactsPath));
assert.ok(
!existsSync(artifactsPath),
`Artifacts folder was not removed: ${artifactsPath}`
);
});
});
13 changes: 13 additions & 0 deletions test/e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
"module": "commonjs" /* Specify what module code is generated. */,
"resolveJsonModule": true /* Enable importing .json files. */,
"outDir": "./out" /* Specify an output folder for all emitted files. */,
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
"strict": true /* Enable all strict type-checking options. */,
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": ["src"]
}
Loading