Skip to content

Commit

Permalink
Migrate Bicep.MSBuild.E2eTests to use vitest (#15272)
Browse files Browse the repository at this point in the history
- Migrated from jest to vitest
- Cleaned up ESLint dependencies and config file

The next step is to consolidate `Bicep.Cli.E2eTests` and
`Bicep.MSBuild.E2eTests` into a mono workspace to further reduce the
maintenance overhead of npm projects..
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/15272)
  • Loading branch information
shenglol authored Nov 1, 2024
1 parent c5f8633 commit 35141e6
Show file tree
Hide file tree
Showing 26 changed files with 2,223 additions and 7,109 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,6 @@ jobs:
run: npm ci
working-directory: ./src/Bicep.MSBuild.E2eTests

- name: Compile
if: matrix.runTests
run: npm run compile
working-directory: ./src/Bicep.MSBuild.E2eTests

- name: Run lint
if: matrix.runTests
run: npm run lint
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/run-formatter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ jobs:
npm run format
working-directory: ./src/Bicep.Cli.E2eTests

- name: Format Bicep.MSBuild.E2eTests
run: |
npm ci
npm run format
working-directory: ./src/Bicep.MSBuild.E2eTests

- name: Format vscode-bicep-ui
run: |
npm ci
Expand Down
7 changes: 4 additions & 3 deletions src/Bicep.Cli.E2eTests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
"vscode-jsonrpc": "^8.2.1"
},
"scripts": {
"test": "vitest local/",
"test:live:prod": "cross-env TEST_ENVIRONMENT=prod vitest live/",
"test:live:ff": "cross-env TEST_ENVIRONMENT=fairfax vitest live/",
"check-types": "tsc --noEmit",
"test": "npm run check-types && vitest local/",
"test:live:prod": "npm run check-types && cross-env TEST_ENVIRONMENT=prod vitest live/",
"test:live:ff": "npm run check-types && cross-env TEST_ENVIRONMENT=fairfax vitest live/",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"format": "prettier --write \"**/*.{js,ts,md}\""
Expand Down
75 changes: 75 additions & 0 deletions src/Bicep.IO/packages.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"version": 1,
"dependencies": {
"net8.0": {
"Microsoft.CodeAnalysis.BannedApiAnalyzers": {
"type": "Direct",
"requested": "[3.3.4, )",
"resolved": "3.3.4",
"contentHash": "0k2Jwpc8eq0hjOtX6TxRkHm9clkJ2PAQ3heEHgqIJZcsfdFosC/iyz18nsgTVDDWpID80rC7aiYK7ripx+Qndg=="
},
"Microsoft.SourceLink.GitHub": {
"type": "Direct",
"requested": "[8.0.0, )",
"resolved": "8.0.0",
"contentHash": "G5q7OqtwIyGTkeIOAc3u2ZuV/kicQaec5EaRnc0pIeSnh9LUjj+PYQrJYBURvDt7twGl2PKA7nSN0kz1Zw5bnQ==",
"dependencies": {
"Microsoft.Build.Tasks.Git": "8.0.0",
"Microsoft.SourceLink.Common": "8.0.0"
}
},
"Microsoft.VisualStudio.Threading.Analyzers": {
"type": "Direct",
"requested": "[17.11.20, )",
"resolved": "17.11.20",
"contentHash": "yI80R8Ja4ipU7/fyVAMCu0oGTN/u97OgL99gd/8ycGnCF58Kn93iBU3T7rkxGMnlsHf5vEgRu95dujtYcgwf9Q=="
},
"Nerdbank.GitVersioning": {
"type": "Direct",
"requested": "[3.6.146, )",
"resolved": "3.6.146",
"contentHash": "W1eQ8hD9Y/cZ2+ilgxECl003xr1hybpN3fMxoTlMqg++BixETBMWzS4y9s08oHJKXgKtudsoxhITNOEf1OR66w=="
},
"System.IO.Abstractions": {
"type": "Direct",
"requested": "[21.0.29, )",
"resolved": "21.0.29",
"contentHash": "EqqngPcNhqjGHKYVjhfU8D/l3rj/m00VaXxuRrWjal38Kw8kqN3f63sj69b/8Q6OAeJkA/nbWsn/iwPMqCQvfg==",
"dependencies": {
"TestableIO.System.IO.Abstractions": "21.0.29",
"TestableIO.System.IO.Abstractions.Wrappers": "21.0.29"
}
},
"Microsoft.Build.Tasks.Git": {
"type": "Transitive",
"resolved": "8.0.0",
"contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ=="
},
"Microsoft.SourceLink.Common": {
"type": "Transitive",
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
"TestableIO.System.IO.Abstractions": {
"type": "Transitive",
"resolved": "21.0.29",
"contentHash": "3TtSs2i0m0QqpAI4EzR1vZXQuHNw5grBy0rDKqMkWi6ySEZ+yhN9HACgIyEq7gDXPLrtQI18ud/OtI0qVhP8Mg=="
},
"TestableIO.System.IO.Abstractions.Wrappers": {
"type": "Transitive",
"resolved": "21.0.29",
"contentHash": "bm1stQx3rGV2qBW2xAAvl8ODVGNVkiAkqNsE+LsKfhMamBUa07IgsgMc9X/zBHc5yfAJOqJIUArQ56DDgwGyYA==",
"dependencies": {
"TestableIO.System.IO.Abstractions": "21.0.29"
}
}
},
"net8.0/linux-arm64": {},
"net8.0/linux-musl-x64": {},
"net8.0/linux-x64": {},
"net8.0/osx-arm64": {},
"net8.0/osx-x64": {},
"net8.0/win-arm64": {},
"net8.0/win-x64": {}
}
}
13 changes: 13 additions & 0 deletions src/Bicep.MSBuild.E2eTests/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"printWidth": 120,
"plugins": ["@ianvs/prettier-plugin-sort-imports"],
"importOrder": [
"<TYPES>^(node:)",
"<TYPES>",
"<TYPES>^[.]",
"",
"<BUILTIN_MODULES>",
"<THIRD_PARTY_MODULES>",
"^[./]"
]
}
37 changes: 0 additions & 37 deletions src/Bicep.MSBuild.E2eTests/Bicep.MSBuild.E2eTests.sln

This file was deleted.

96 changes: 29 additions & 67 deletions src/Bicep.MSBuild.E2eTests/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,73 +1,35 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// @ts-check
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import vitest from "@vitest/eslint-plugin";
import notice from "eslint-plugin-notice";
import tsParser from "@typescript-eslint/parser";
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [{
ignores: ["out/**/*"],
}, ...compat.extends("eslint:recommended", "plugin:prettier/recommended"), {
plugins: {
notice,
},

languageOptions: {
parser: tsParser,
ecmaVersion: 2020,
sourceType: "module",

parserOptions: {
project: "./tsconfig.json",
},
},

rules: {
"notice/notice": [
2,
{
"templateFile": "../copyright-template.js",
}
]
export default tseslint.config({
files: ["src/**/*.ts"],
extends: [eslint.configs.recommended, ...tseslint.configs.recommended],
languageOptions: {
ecmaVersion: 2020,
globals: {
...vitest.environments.env.globals,
},
}, ...compat.extends(
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"plugin:prettier/recommended",
).map(config => ({
...config,
files: ["**/*.ts"],
})), {
files: ["**/*.ts"],

rules: {
"jest/no-hooks": "off",
"jest/prefer-expect-assertions": "off",

"jest/expect-expect": ["error", {
assertFunctionNames: ["expect*"],
}],

"jest/prefer-importing-jest-globals": "off",
},
}, {
files: ["**/*.js"],

languageOptions: {
globals: {
...globals.node,
},
},
}];
},
plugins: { notice, vitest },
rules: {
"notice/notice": [
"error",
{
templateFile: "../copyright-template.js",
},
],
...vitest.configs.recommended.rules,
"vitest/expect-expect": [
"error",
{
assertFunctionNames: ["expect", "expect*", "**.expect*"],
},
],
},
});
12 changes: 0 additions & 12 deletions src/Bicep.MSBuild.E2eTests/jest.config.ado.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/Bicep.MSBuild.E2eTests/jest.config.js

This file was deleted.

Loading

0 comments on commit 35141e6

Please sign in to comment.