Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: run tests with coverage #676

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -34,12 +34,12 @@ jobs:
echo "NODE_ENV=test" >> packages/core/.env.test
- name: Run tests
run: cd packages/core && pnpm test
run: cd packages/core && pnpm test:coverage

- name: Build packages
run: pnpm run build

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
"dev": "tsup --format esm --dts --watch",
"build:docs": "cd docs && pnpm run build",
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"test:watch": "vitest"
},
"author": "",
@@ -34,6 +35,7 @@
"@types/wav-encoder": "1.3.3",
"@typescript-eslint/eslint-plugin": "8.12.2",
"@typescript-eslint/parser": "8.12.2",
"@vitest/coverage-v8": "2.1.5",
"dotenv": "16.4.5",
"eslint": "^9.15.0",
"eslint-config-prettier": "9.1.0",
34,695 changes: 19,392 additions & 15,303 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -34,8 +34,16 @@ for package in "${PACKAGES[@]}"; do
cd "$package_path" || continue

if [ -f "package.json" ]; then
# Run tests if available
if npm run | grep -q " test"; then
# Run tests with coverage if TEST_COVERAGE is set and test:coverage script exists
if [[ -n "$TEST_COVERAGE" ]] && npm run | grep -q " test:coverage"; then
echo -e "\033[1mRunning coverage tests for package: $package\033[0m"
if npm run test:coverage; then
echo -e "\033[1;32mSuccessfully tested $package with coverage\033[0m\n"
else
echo -e "\033[1;31mCoverage tests failed for $package\033[0m"
fi
# Otherwise, run regular tests if available
elif npm run | grep -q " test"; then
echo -e "\033[1mRunning tests for package: $package\033[0m"
if npm run test; then
echo -e "\033[1;32mSuccessfully tested $package\033[0m\n"
@@ -52,4 +60,4 @@ for package in "${PACKAGES[@]}"; do
cd - > /dev/null || exit
done

echo -e "\033[1mTest process completed.😎\033[0m"
echo -e "\033[1mTest process completed.😎\033[0m"

Unchanged files with check annotations Beta

});
}
async sendMessage(message: WhatsAppMessage): Promise<any> {

Check warning on line 19 in packages/plugin-whatsapp/src/client.ts

GitHub Actions / check

Unexpected any. Specify a different type
const endpoint = `/${this.config.phoneNumberId}/messages`;
const payload = {
export class MessageHandler {
constructor(private client: WhatsAppClient) {}
async send(message: WhatsAppMessage): Promise<any> {

Check warning on line 7 in packages/plugin-whatsapp/src/handlers/message.handler.ts

GitHub Actions / check

Unexpected any. Specify a different type
try {
const response = await this.client.sendMessage(message);
return response.data;
}
}
private async handleMessage(message: any): Promise<void> {

Check warning on line 29 in packages/plugin-whatsapp/src/handlers/webhook.handler.ts

GitHub Actions / check

Unexpected any. Specify a different type
// Implement message handling logic
// This could emit events or trigger callbacks based on your framework's needs
console.log('Received message:', message);

Check warning on line 32 in packages/plugin-whatsapp/src/handlers/webhook.handler.ts

GitHub Actions / check

Unexpected console statement
}
private async handleStatus(status: any): Promise<void> {

Check warning on line 35 in packages/plugin-whatsapp/src/handlers/webhook.handler.ts

GitHub Actions / check

Unexpected any. Specify a different type
// Implement status update handling logic
// This could emit events or trigger callbacks based on your framework's needs
console.log('Received status update:', status);

Check warning on line 38 in packages/plugin-whatsapp/src/handlers/webhook.handler.ts

GitHub Actions / check

Unexpected console statement
}
}
this.webhookHandler = new WebhookHandler(this.client);
}
async sendMessage(message: WhatsAppMessage): Promise<any> {

Check warning on line 17 in packages/plugin-whatsapp/src/index.ts

GitHub Actions / check

Unexpected any. Specify a different type
return this.messageHandler.send(message);
}