Skip to content

Commit

Permalink
vitest setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Donham committed May 28, 2024
1 parent 695a4ff commit a3971d1
Show file tree
Hide file tree
Showing 6 changed files with 401 additions and 47 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
"patchedDependencies": {
"[email protected]": "patches/[email protected]"
}
},
"devDependencies": {
"vitest": "^1.6.0"
}
}
14 changes: 14 additions & 0 deletions packages/server/src/rewrite.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { expect, it } from "vitest";
import rewrite from "./rewrite";

it("rewrites", () => {
const code = "{ foo: 'bar' }";
const language = "typescript";
const id = "id";
const cellId = "cellId";
const cells = new Map();

const result = rewrite(code, language, id, cellId, cells);

expect(result.code).toEqual("export default {\n foo: 'bar'\n};");
});
12 changes: 10 additions & 2 deletions packages/server/src/rewrite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ import * as babelParser from "@babel/parser";
import _babelTraverse from "@babel/traverse";
import * as babelTypes from "@babel/types";
import type { Cell, SourceDescription } from "./types";
const babelGenerator: typeof _babelGenerator = (_babelGenerator as any).default;
const babelTraverse: typeof _babelTraverse = (_babelTraverse as any).default;

// ESM / CJS interop nonsense
const babelGenerator: typeof _babelGenerator =
typeof _babelGenerator === "function"
? _babelGenerator
: (_babelGenerator as any).default;
const babelTraverse: typeof _babelTraverse =
typeof _babelTraverse === "function"
? _babelTraverse
: (_babelTraverse as any).default;

const reactImports = babelParser.parse(
`
Expand Down
15 changes: 0 additions & 15 deletions packages/vscode/src/test/extension.test.ts

This file was deleted.

Loading

0 comments on commit a3971d1

Please sign in to comment.