Skip to content

Commit

Permalink
add dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteXyy committed Dec 22, 2023
1 parent fa51449 commit ff1de62
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:18

WORKDIR /app

COPY . .

RUN yarn

CMD [ "yarn", "test" ]
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
https://github.com/vitest-dev/vitest/issues/3077#issuecomment-1867306736

```sh
docker build . -t vitest
docker run -it -v ./src:/app/src vitest /bin/bash
```

Play with configs, my findings:
1. It is more likely to hang when test cases failed. (not sure, you can try comment & uncomment `data-testid="message"` in Message.tsx)
2. Node 18/19 will hang, while it seems that there are no issues with version 20+.
3. Setting `globals: true` and using the global vitest function increases the possibility of hanging.
4. The higher count of tests, the higher the chance of hanging.



4 changes: 2 additions & 2 deletions src/Message.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cleanup, render, screen } from "@testing-library/react";
import Message from "./Message";
import { describe, it, expect, beforeEach } from "vitest";
// import { describe, it, expect, beforeEach } from "vitest";

beforeEach(cleanup);

Expand All @@ -23,5 +23,5 @@ describe(
expect(messageElement.innerHTML).toBe("<b>test</b> abc");
});
},
{ repeats: 200 }
{ repeats: 500 }
);
2 changes: 1 addition & 1 deletion src/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const dompurify = DOMPurify();
const SystemMessage = ({ text }: { text: string }) => {
return (
<div
// data-testid="message"
data-testid="message"
dangerouslySetInnerHTML={{ __html: dompurify.sanitize(text) }}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { defineConfig } from "vitest/config";
export default defineConfig({
plugins: [react()],
test: {
// globals: true,
globals: true,
setupFiles: ["./src/setupTests.ts"],
environment: "jsdom",
},
Expand Down

0 comments on commit ff1de62

Please sign in to comment.