This directory contains the test suite for the Flux Mobile CLI tool.
tests/
├── commands/ # Unit tests for CLI commands
│ └── init.test.js # Tests for init command
├── utils/ # Unit tests for utility functions
│ ├── config.test.js
│ ├── ipa-parser.test.js
│ └── appstore-api.test.js
├── validation/ # Input validation tests
│ └── input-validation.test.js
├── integration/ # Integration tests (end-to-end workflows)
│ └── build-workflow.test.js
└── README.md # This file
npm testnpm run test:watchnpm run test:coveragenpm test -- tests/utils/ipa-parser.test.jsnpm test -- --testNamePattern="formatReleaseNotes"- Test individual functions and modules in isolation
- Mock external dependencies (file system, API calls, etc.)
- Fast execution, run on every commit
- Test input validation logic
- Ensure proper error handling for invalid inputs
- Test edge cases and boundary conditions
- Test complete workflows (build → deploy)
- Require actual tools (Flutter, Xcode, etc.)
- May be skipped in CI if dependencies are unavailable
- Marked with
.skipfor optional execution
import { describe, test, expect } from "@jest/globals";
import { myFunction } from "../../utils/my-module.js";
describe("My Module", () => {
test("should do something correctly", () => {
const result = myFunction("input");
expect(result).toBe("expected output");
});
});import { describe, test, expect } from "@jest/globals";
import { execSync } from "child_process";
describe("Build Integration", () => {
test("should build APK successfully", async () => {
// Setup test project
// Run flux build command
// Verify output artifact exists
});
});For tests that interact with external APIs or file system:
import { jest } from "@jest/globals";
import fs from "fs-extra";
// Mock fs module
jest.mock("fs-extra");
test("should handle file operations", async () => {
fs.readFile.mockResolvedValue("mocked content");
// ... test code
});Aim for:
- 80%+ coverage for core utilities (
utils/) - 70%+ coverage for commands (
commands/) - 100% coverage for validation logic
View coverage report:
npm run test:coverage
open coverage/index.htmlTests run automatically on:
- Every commit (unit tests only)
- Pull requests (unit + validation tests)
- Release branches (full test suite including integration tests)
Some integration tests require:
- Flutter SDK
- Xcode (macOS only)
- Android SDK
These tests are marked with .skip and won't fail CI.
Ensure test directories are cleaned up:
rm -rf .test-* coverageEnsure you're using ES modules syntax:
import { test } from "@jest/globals"; // ✅ Correct
const { test } = require("@jest/globals"); // ❌ Wrong- Add E2E tests with real Flutter/RN projects
- Add API mocking for App Store Connect and Google Play APIs
- Add performance benchmarks
- Add snapshot testing for CLI output
- Add mutation testing for critical paths