From 985485f2e1cbe8eec7cfbedd522cb453526b8338 Mon Sep 17 00:00:00 2001
From: jerrywu001 <57242263@163.com>
Date: Fri, 2 Sep 2022 16:28:06 +0800
Subject: [PATCH] fix: test components bug
---
README.md | 26 +-
global.d.ts | 5 +
package.json | 4 +-
playground/src/pages/index.vue | 21 +-
playground/stories/Console.stories.tsx | 58 +-
playground/stories/Tests.stories.tsx | 224 ++++----
playground/stories/main.stories.tsx | 108 ++--
src/components/console/SandpackConsole.tsx | 11 +-
src/components/console/useSandpackConsole.ts | 9 +-
.../console/utils/fromConsoleToString.test.ts | 151 -----
src/components/preview/index.tsx | 2 +
src/components/tests/SandpackTests.tsx | 519 +++++++++---------
src/contexts/sandpackContext.tsx | 9 +-
src/hooks/useSandpackClient.ts | 7 +-
src/presets/Sandpack.tsx | 24 +-
src/presets/SandpackRender.tsx | 6 +-
16 files changed, 560 insertions(+), 624 deletions(-)
delete mode 100644 src/components/console/utils/fromConsoleToString.test.ts
diff --git a/README.md b/README.md
index 8e70ae0..a985857 100644
--- a/README.md
+++ b/README.md
@@ -12,6 +12,20 @@ import { Sandpack } from 'codesandbox-sandpack-vue3';
[Read more](https://sandpack.codesandbox.io/)
+## online demo
+
+[demo](https://stackblitz.com/edit/vitejs-vite-s6jdds)
+
+[ssg demo](https://stackblitz.com/edit/vitejs-vite-ha17a9)
+
+*Here's an example of a react version for comparison*
+
+https://stackblitz.com/edit/vitejs-vite-axyaxx
+
+## releases
+
+https://github.com/jerrywu001/sandpack-vue3/releases
+
## Sandpack Themes
A list of themes to customize your Sandpack components.
@@ -30,16 +44,6 @@ For full documentation, visit [https://sandpack.codesandbox.io/docs/](https://sa
**This project removes [devtools component && useSandpackLint hook]**
-## online demo
-
-[demo](https://stackblitz.com/edit/vitejs-vite-s6jdds)
-
-[ssg demo](https://stackblitz.com/edit/vitejs-vite-ha17a9)
-
-*Here's an example of a react version for comparison*
-
-https://stackblitz.com/edit/vitejs-vite-axyaxx
-
## SSG/SSR
@@ -69,6 +73,8 @@ app.use(SanpackPlugin());
- [Sandpack](https://sandpack.codesandbox.io/docs/api/react/#sandpack)
- [SandpackLayout](https://sandpack.codesandbox.io/docs/api/react/interfaces/SandpackLayoutProps)
+- [SandpackConsole](https://sandpack.codesandbox.io/docs/advanced-usage/components#console)
+- [SandpackTests](https://sandpack.codesandbox.io/docs/advanced-usage/components#tests)
- [CodeEditor](https://sandpack.codesandbox.io/docs/api/react/#codeeditor)
- [SandpackProvider](https://sandpack.codesandbox.io/docs/api/react/classes/SandpackProvider)
- [ErrorOverlay](https://sandpack.codesandbox.io/docs/api/react/#erroroverlay)
diff --git a/global.d.ts b/global.d.ts
index 7ffc7d7..9769cb4 100644
--- a/global.d.ts
+++ b/global.d.ts
@@ -2,6 +2,8 @@ import '@vue/runtime-core';
import {
Sandpack,
SandpackLayout,
+ SandpackConsole,
+ SandpackTests,
CodeEditor,
SandpackProvider,
ErrorOverlay,
@@ -18,6 +20,9 @@ declare module '@vue/runtime-core' {
export interface GlobalComponents {
Sandpack: typeof Sandpack;
SandpackLayout: typeof SandpackLayout;
+ SandpackConsole: typeof SandpackConsole;
+ SandpackTests: typeof SandpackTests;
+ SandpackLayout: typeof SandpackLayout;
SandpackProvider: typeof SandpackProvider;
ErrorOverlay: typeof ErrorOverlay;
LoadingOverlay: typeof LoadingOverlay;
diff --git a/package.json b/package.json
index 6bcffd7..ce115ae 100644
--- a/package.json
+++ b/package.json
@@ -91,7 +91,7 @@
"@storybook/addon-links": "~6.4.22",
"@storybook/builder-vite": "0.1.37",
"@storybook/vue3": "~6.4.22",
- "@swc/core": "^1.2.245",
+ "@swc/core": "^1.2.246",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/user-event": "^14.4.3",
"@testing-library/vue": "^6.6.1",
@@ -122,7 +122,7 @@
"husky": "^8.0.1",
"jsdom": "^20.0.0",
"lint-staged": "^13.0.3",
- "npm": "^8.19.0",
+ "npm": "^8.19.1",
"postcss": "^8.4.16",
"postcss-cli": "^10.0.0",
"postcss-loader": "^7.0.1",
diff --git a/playground/src/pages/index.vue b/playground/src/pages/index.vue
index 0431e11..57fc088 100644
--- a/playground/src/pages/index.vue
+++ b/playground/src/pages/index.vue
@@ -3,12 +3,11 @@ import isEqual from 'lodash.isequal';
import { ref } from 'vue';
import { githubLight, aquaBlue } from '@codesandbox/sandpack-themes';
import {
- // Sandpack,
+ Sandpack,
// SandpackLayout,
// SandpackTranspiledCode,
// SandpackProvider,
// SandpackCodeEditor,
- SandpackConsole,
SandpackPredefinedTemplate,
SandpackTheme,
} from 'codesandbox-sandpack-vue3';
@@ -70,22 +69,34 @@ const toggleReadOnly = () => {
showReadOnly: true,
readOnly: readOnly,
wrapContent: wrapContent,
+ showConsoleButton: true,
+ showConsole: false,
}"
/>
+
showConsoleButton: false, showConsole: false
showConsoleButton: true, showConsole: true
showConsoleButton: false, showConsole: true
showConsoleButton: true, showConsole: false
No test files found.
@@ -478,16 +475,16 @@ export const SandpackTests = defineComponent({
<>