Skip to content

Commit

Permalink
update setupTypeScript to add compiler options and moduleFileExtentions
Browse files Browse the repository at this point in the history
  • Loading branch information
bmw2621 committed Jul 28, 2021
1 parent c551a5c commit 1ecca3a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
8 changes: 7 additions & 1 deletion scripts/setupTypeScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ packageJSON.jest.transform["^.+\\.svelte$"] = [
packageJSON.jest.transform = Object.assign(packageJSON.jest.transform, {
"^.+\\.ts$": "ts-jest",
});
packageJSON.jest.moduleFileExtensions = [
...packageJSON.jest.moduleFileExtensions,
"ts",
];

// Write the package JSON
fs.writeFileSync(
Expand Down Expand Up @@ -101,6 +105,8 @@ const tsconfig = `{
"include": ["src/**/*"],
"exclude": ["node_modules/*", "__sapper__/*", "public/*"]
"compilerOptions":{"types":["jest"]}
}`;
const tsconfigPath = path.join(projectRoot, "tsconfig.json");
fs.writeFileSync(tsconfigPath, tsconfig);
Expand All @@ -110,7 +116,7 @@ const dtsPath = path.join(projectRoot, "src", "global.d.ts");
fs.writeFileSync(dtsPath, `/// <reference types="svelte" />`);

// Add svelte.config.js
const svelteConfigPath = path.join(projectRoot, "src", "svelte.config.js");
const svelteConfigPath = path.join(projectRoot, "svelte.config.js");
fs.writeFileSync(
svelteConfigPath,
`const sveltePreprocess = require("svelte-preprocess");
Expand Down
2 changes: 1 addition & 1 deletion src/App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { render } from "@testing-library/svelte";
import AppComponent from "./App.svelte";

test("shows proper heading when rendered", () => {
const { getByText } = render(AppComponent, { name: "World" });
const { getByText } = render(AppComponent, { props: { name: "World" } });

expect(getByText("Hello World!")).toBeInTheDocument();
});
7 changes: 0 additions & 7 deletions svelte.config.js

This file was deleted.

0 comments on commit 1ecca3a

Please sign in to comment.