Skip to content

Commit

Permalink
Typecheck the tests in CI.
Browse files Browse the repository at this point in the history
Neither CRA's build nor test steps do this.

Fix various minor typing errors to get this clean again.

facebook/create-react-app#5626
  • Loading branch information
microbit-matt-hillsdon committed Jan 25, 2022
1 parent 278f6a7 commit a10ab36
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@
"scripts": {
"bundle-size-explorer": "source-map-explorer 'build/static/js/*.js'",
"bundle-size-report": "source-map-explorer 'build/static/js/*.js' --html reports/bundle-size.html",
"ci": "npm run test && npm run build && npm run bundle-size-report",
"ci": "npm run typecheck && npm run test && npm run build && npm run bundle-size-report",
"start": "craco start",
"build": "craco build",
"test": "craco test --testPathIgnorePatterns=e2e",
"eject": "craco eject",
"serve": "npx serve --no-clipboard -l 3000 -- build/",
"typecheck": "tsc --noEmit",
"test:all": "craco test --testTimeout 15000",
"test:e2e": "craco test --testPathPattern e2e -w 1 --testTimeout 15000",
"test:e2e:headless": "CI=true npm run test:e2e",
Expand Down
2 changes: 1 addition & 1 deletion src/common/sanity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export interface PortableTextBlock {
}

export type PortableText = Array<
PortableTextBlock | { _type: string; children?: any }
PortableTextBlock | { _type: string; children?: any; [other: string]: any }
>;
1 change: 0 additions & 1 deletion src/documentation/common/DocString.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* SPDX-License-Identifier: MIT
*/
import { render } from "@testing-library/react";
import { renderMarkdown } from "../editor/codemirror/language-server/documentation";
import DocString from "./DocString";

describe("DocString", () => {
Expand Down
8 changes: 4 additions & 4 deletions src/documentation/explore/ToolkitContent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jest.mock("@chakra-ui/image", () => ({

import { ImageProps } from "@chakra-ui/react";
import { render } from "@testing-library/react";
import { ToolkitPortableText } from "./model";
import ToolkitContent, { imageUrlBuilder } from "./ToolkitContent";
import { PortableText } from "../../common/sanity";
import ToolkitContent from "./ToolkitContent";

describe("ToolkitContent", () => {
it("renders external links", () => {
const content: ToolkitPortableText = [
const content: PortableText = [
{
_key: "aa98d45c4830",
_type: "block",
Expand Down Expand Up @@ -51,7 +51,7 @@ describe("ToolkitContent", () => {
});

it("renders images", () => {
const content: ToolkitPortableText = [
const content: PortableText = [
{
_type: "simpleImage",
alt: "micro:bit showing X axis going across the front, Y axis going down and up, Z axis going back to front",
Expand Down
4 changes: 2 additions & 2 deletions src/documentation/search/blocks-to-text.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
*
* SPDX-License-Identifier: MIT
*/
import { PortableText } from "../../common/sanity";
import { blocksToText } from "./blocks-to-text";
import { ToolkitPortableText } from "../explore/model";

const content: ToolkitPortableText[] = [
const content: PortableText[] = [
[
{
_key: "41931367cb0c",
Expand Down
10 changes: 6 additions & 4 deletions src/fs/storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
SplitStrategyStorage,
} from "./storage";

const projectName = "projectName";

const commonStorageTests = (storage: FSStorage) => {
it("is empty", async () => {
expect(await storage.ls()).toEqual([]);
Expand Down Expand Up @@ -67,7 +69,7 @@ describe("SessionStorageFSStorage", () => {
});

describe("InMemoryFSStorage", () => {
const storage = new InMemoryFSStorage();
const storage = new InMemoryFSStorage(projectName);
beforeEach(() => {
storage.clear();
});
Expand All @@ -76,7 +78,7 @@ describe("InMemoryFSStorage", () => {

describe("SplitStrategyStorage", () => {
const storage = new SplitStrategyStorage(
new InMemoryFSStorage(),
new InMemoryFSStorage(projectName),
new SessionStorageFSStorage(sessionStorage),
new NullLogging()
);
Expand All @@ -88,7 +90,7 @@ describe("SplitStrategyStorage", () => {
commonStorageTests(storage);

it("initializes from session storage", async () => {
const memory = new InMemoryFSStorage();
const memory = new InMemoryFSStorage(projectName);
const session = new SessionStorageFSStorage(sessionStorage);
session.write("test1.py", new Uint8Array([1]));

Expand All @@ -98,7 +100,7 @@ describe("SplitStrategyStorage", () => {
});

it("clears and stops using session storage if we hit errors", async () => {
const memory = new InMemoryFSStorage();
const memory = new InMemoryFSStorage(projectName);
const session = new SessionStorageFSStorage(sessionStorage);

const log = new MockLogging();
Expand Down

0 comments on commit a10ab36

Please sign in to comment.