mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-21 11:35:34 +01:00
Return error code when any tsc typecheck fails (#5459)
* Return error code when any tsc typecheck fails * Try with bash `sh ./scripts/test-types.s` resulted in errors missing `[[`, which is a bash builtin. It's possible the ubuntu runner is using some other shell. * Fix spec type errors * Switch to node for Windows compatibility
This commit is contained in:
parent
1caae996ff
commit
c58b0c0753
@ -27,3 +27,5 @@ apps/cli/config/config.js
|
|||||||
tailwind.config.js
|
tailwind.config.js
|
||||||
libs/components/tailwind.config.base.js
|
libs/components/tailwind.config.base.js
|
||||||
libs/components/tailwind.config.js
|
libs/components/tailwind.config.js
|
||||||
|
|
||||||
|
scripts/*.js
|
||||||
|
@ -7,7 +7,7 @@ import {
|
|||||||
describe("ServerConfigData", () => {
|
describe("ServerConfigData", () => {
|
||||||
describe("fromJSON", () => {
|
describe("fromJSON", () => {
|
||||||
it("should create a ServerConfigData from a JSON object", () => {
|
it("should create a ServerConfigData from a JSON object", () => {
|
||||||
const serverConfigData = ServerConfigData.fromJSON({
|
const json = {
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
gitHash: "1234567890",
|
gitHash: "1234567890",
|
||||||
server: {
|
server: {
|
||||||
@ -22,18 +22,11 @@ describe("ServerConfigData", () => {
|
|||||||
sso: "https://sso.com",
|
sso: "https://sso.com",
|
||||||
},
|
},
|
||||||
utcDate: "2020-01-01T00:00:00.000Z",
|
utcDate: "2020-01-01T00:00:00.000Z",
|
||||||
});
|
featureStates: { feature: "state" },
|
||||||
|
};
|
||||||
|
const serverConfigData = ServerConfigData.fromJSON(json);
|
||||||
|
|
||||||
expect(serverConfigData.version).toEqual("1.0.0");
|
expect(serverConfigData).toEqual(json);
|
||||||
expect(serverConfigData.gitHash).toEqual("1234567890");
|
|
||||||
expect(serverConfigData.server.name).toEqual("test");
|
|
||||||
expect(serverConfigData.server.url).toEqual("https://test.com");
|
|
||||||
expect(serverConfigData.environment.vault).toEqual("https://vault.com");
|
|
||||||
expect(serverConfigData.environment.api).toEqual("https://api.com");
|
|
||||||
expect(serverConfigData.environment.identity).toEqual("https://identity.com");
|
|
||||||
expect(serverConfigData.environment.notifications).toEqual("https://notifications.com");
|
|
||||||
expect(serverConfigData.environment.sso).toEqual("https://sso.com");
|
|
||||||
expect(serverConfigData.utcDate).toEqual("2020-01-01T00:00:00.000Z");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be an instance of ServerConfigData", () => {
|
it("should be an instance of ServerConfigData", () => {
|
||||||
|
@ -62,8 +62,9 @@ describe("ImportService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("has the promptForPassword_callback set", async () => {
|
it("has the promptForPassword_callback set", async () => {
|
||||||
expect(importer.promptForPassword_callback).not.toBeNull();
|
// Cast to any to access private property. Note: assumes instance of BitwardenPasswordProtectedImporter
|
||||||
expect(await importer.promptForPassword_callback()).toEqual(password);
|
expect((importer as any).promptForPassword_callback).not.toBeNull();
|
||||||
|
expect(await (importer as any).promptForPassword_callback()).toEqual(password);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has the appropriate organization Id", () => {
|
it("has the appropriate organization Id", () => {
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:watch": "jest --clearCache && jest --watch",
|
"test:watch": "jest --clearCache && jest --watch",
|
||||||
"test:watch:all": "jest --watchAll",
|
"test:watch:all": "jest --watchAll",
|
||||||
"test:types": "for p in libs/**/tsconfig.spec.json; do echo \"Typechecking $p\"; tsc --noEmit --project $p; done",
|
"test:types": "node ./scripts/test-types.js",
|
||||||
"docs:json": "compodoc -p ./tsconfig.json -e json -d .",
|
"docs:json": "compodoc -p ./tsconfig.json -e json -d .",
|
||||||
"storybook": "npm run docs:json && start-storybook -p 6006",
|
"storybook": "npm run docs:json && start-storybook -p 6006",
|
||||||
"build-storybook": "npm run docs:json && build-storybook",
|
"build-storybook": "npm run docs:json && build-storybook",
|
||||||
|
29
scripts/test-types.js
Normal file
29
scripts/test-types.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
const concurrently = require("concurrently");
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
|
function getFiles(dir) {
|
||||||
|
results = [];
|
||||||
|
fs.readdirSync(dir).forEach((file) => {
|
||||||
|
file = path.join(dir, file);
|
||||||
|
const stat = fs.statSync(file);
|
||||||
|
if (stat && stat.isDirectory()) {
|
||||||
|
results = results.concat(getFiles(file));
|
||||||
|
} else {
|
||||||
|
results.push(file);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
const files = getFiles(path.join(__dirname, "..", "libs")).filter((file) => {
|
||||||
|
const name = path.basename(file);
|
||||||
|
return name === "tsconfig.spec.json";
|
||||||
|
});
|
||||||
|
|
||||||
|
concurrently(
|
||||||
|
files.map((file) => ({
|
||||||
|
name: path.basename(path.dirname(file)),
|
||||||
|
command: `npx tsc --noEmit --project ${file}`,
|
||||||
|
}))
|
||||||
|
);
|
Loading…
Reference in New Issue
Block a user