From 259136afa2a4750bb9ee2fe379152c8e8c24fd0a Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Wed, 11 Dec 2024 15:00:19 +0100 Subject: [PATCH] Add an example to run vitest tests --- README.md | 1 + package.json | 3 ++- .../bin/knapsack_pro_vitest | 19 +++++++++++++++++++ .../vitest-example-test-suite/package.json | 3 ++- 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100755 packages/vitest-example-test-suite/bin/knapsack_pro_vitest diff --git a/README.md b/README.md index 448744bb..357de7b8 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ npm install ``` npm run test:core:coverage npm run test:jest +npm run test:vitest npm run test:cypress npm run test:cra ``` diff --git a/package.json b/package.json index 604d0748..5d237c11 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,9 @@ "lint": "npm run lint --workspaces --if-present", "test:core:coverage": "npm run test:coverage -w packages/core", "test:jest": "npm run build && npm run test:ks -w packages/jest-example-test-suite", + "test:vitest": "npm run build && npm run test:ks -w packages/vitest-example-test-suite", "test:cypress": "npm run build && npm run test:ks -w packages/cypress-example-test-suite", "test:cra": "cd packages/create-react-app-example && npm install && npm run test:ks", - "test:examples": "npm run test:jest && npm run test:cypress && npm run test:cra" + "test:examples": "npm run test:jest && npm run test:vitest && npm run test:cypress && npm run test:cra" } } diff --git a/packages/vitest-example-test-suite/bin/knapsack_pro_vitest b/packages/vitest-example-test-suite/bin/knapsack_pro_vitest new file mode 100755 index 00000000..58f6f74d --- /dev/null +++ b/packages/vitest-example-test-suite/bin/knapsack_pro_vitest @@ -0,0 +1,19 @@ +#!/bin/bash + +CI_BUILD_ID=$(openssl rand -base64 32) + +ENDPOINT=https://api-staging.knapsackpro.com +# ENDPOINT=http://api.knapsackpro.test:3000 + +LOG_LEVEL=info +# LOG_LEVEL=debug + +# TODO remove KNAPSACK_PRO_TEST_SUITE_TOKEN once we start using KNAPSACK_PRO_TEST_SUITE_TOKEN_VITEST +KNAPSACK_PRO_ENDPOINT=$ENDPOINT \ + KNAPSACK_PRO_TEST_SUITE_TOKEN=d264b4b40f900d79178ca63e7ffc971f \ + KNAPSACK_PRO_TEST_SUITE_TOKEN_VITEST=d264b4b40f900d79178ca63e7ffc971f \ + KNAPSACK_PRO_LOG_LEVEL=$LOG_LEVEL \ + KNAPSACK_PRO_CI_NODE_BUILD_ID=$CI_BUILD_ID \ + KNAPSACK_PRO_CI_NODE_TOTAL=${2:-2} \ + KNAPSACK_PRO_CI_NODE_INDEX=${1:-0} \ + npx @knapsack-pro/vitest --verbose diff --git a/packages/vitest-example-test-suite/package.json b/packages/vitest-example-test-suite/package.json index 41342b4e..9e999a32 100644 --- a/packages/vitest-example-test-suite/package.json +++ b/packages/vitest-example-test-suite/package.json @@ -9,7 +9,8 @@ "vitest": "^2.1.6" }, "scripts": { - "test": "vitest" + "test": "vitest", + "test:ks": "bin/knapsack_pro_vitest" }, "repository": { "type": "git",