-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/aws-samples/aws-genai-cicd-…
…suite into main
- Loading branch information
Showing
4 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Auto-Generated Unit Tests | ||
|
||
This document provides an overview of the automatically generated unit tests for this project. | ||
|
||
## Generated Test Suites | ||
|
||
- **sample.test.ts**: Tests for `sample.ts` | ||
- Location: `test/sample.test.ts` | ||
- Source file: `debugging/sample.ts` | ||
|
||
- **testUtils.test.ts**: Tests for `testUtils.ts` | ||
- Location: `test/testUtils.test.ts` | ||
- Source file: `debugging/testUtils.ts` | ||
|
||
- **utils.test.ts**: Tests for `utils.ts` | ||
- Location: `test/utils.test.ts` | ||
- Source file: `debugging/utils.ts` | ||
|
||
## Test Coverage | ||
|
||
The following test coverage was achieved during the pre-flight phase: | ||
|
||
``` | ||
{ | ||
"lines": { | ||
"total": 0, | ||
"covered": 0, | ||
"skipped": 0, | ||
"pct": 100 | ||
}, | ||
"statements": { | ||
"total": 0, | ||
"covered": 0, | ||
"skipped": 0, | ||
"pct": 100 | ||
}, | ||
"functions": { | ||
"total": 0, | ||
"covered": 0, | ||
"skipped": 0, | ||
"pct": 100 | ||
}, | ||
"branches": { | ||
"total": 0, | ||
"covered": 0, | ||
"skipped": 0, | ||
"pct": 100 | ||
} | ||
} | ||
``` | ||
|
||
## Test Results Summary | ||
|
||
Total tests: 33 | ||
Passed tests: 3 | ||
Failed tests: 30 | ||
|
||
## Running Tests Manually | ||
|
||
To run these unit tests manually, follow these steps: | ||
|
||
1. Ensure you have Node.js and npm installed on your system. | ||
2. Navigate to the project root directory in your terminal. | ||
3. Install the necessary dependencies by running: | ||
``` | ||
npm install | ||
``` | ||
4. Run the tests using the following command: | ||
``` | ||
npm test | ||
``` | ||
|
||
This will execute all the unit tests in the `test` directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { add, subtract } from '/home/runner/work/aws-genai-cicd-suite/aws-genai-cicd-suite/debugging/sample'; | ||
|
||
describe('add', () => { | ||
it('should add two positive numbers correctly', () => { | ||
expect(add(2, 3)).toBe(5); | ||
}); | ||
|
||
it('should add two negative numbers correctly', () => { | ||
expect(add(-2, -3)).toBe(-5); | ||
}); | ||
|
||
it('should add a positive and a negative number correctly', () => { | ||
expect(add(2, -3)).toBe(-1); | ||
}); | ||
|
||
it('should add zero to a number correctly', () => { | ||
expect(add(0, 5)).toBe(5); | ||
expect(add(5, 0)).toBe(5); | ||
}); | ||
}); | ||
|
||
describe('subtract', () => { | ||
it('should subtract two positive numbers correctly', () => { | ||
expect(subtract(5, 3)).toBe(2); | ||
}); | ||
|
||
it('should subtract two negative numbers correctly', () => { | ||
expect(subtract(-5, -3)).toBe(-2); | ||
}); | ||
|
||
it('should subtract a negative number from a positive number correctly', () => { | ||
expect(subtract(5, -3)).toBe(8); | ||
}); | ||
|
||
it('should subtract a positive number from a negative number correctly', () => { | ||
expect(subtract(-5, 3)).toBe(-8); | ||
}); | ||
|
||
it('should subtract zero from a number correctly', () => { | ||
expect(subtract(5, 0)).toBe(5); | ||
expect(subtract(0, 5)).toBe(-5); | ||
}); | ||
}); | ||
|
||
import { subtract } from '/home/runner/work/aws-genai-cicd-suite/aws-genai-cicd-suite/debugging/sample'; | ||
|
||
describe('subtract', () => { | ||
it('should subtract two positive numbers correctly', () => { | ||
expect(subtract(5, 3)).toBe(2); | ||
}); | ||
|
||
it('should subtract two negative numbers correctly', () => { | ||
expect(subtract(-10, -5)).toBe(-5); | ||
}); | ||
|
||
it('should subtract a positive number from a negative number correctly', () => { | ||
expect(subtract(-8, 3)).toBe(-11); | ||
}); | ||
|
||
it('should subtract a negative number from a positive number correctly', () => { | ||
expect(subtract(10, -4)).toBe(14); | ||
}); | ||
|
||
it('should return 0 when subtracting the same number', () => { | ||
expect(subtract(7, 7)).toBe(0); | ||
}); | ||
|
||
it('should handle large numbers correctly', () => { | ||
expect(subtract(1000000000, 500000000)).toBe(500000000); | ||
}); | ||
|
||
it('should handle floating-point numbers correctly', () => { | ||
expect(subtract(3.14, 1.57)).toBeCloseTo(1.57, 5); | ||
}); | ||
}); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { shouldExcludeFile } from '@/debugging/utils'; | ||
|
||
describe('shouldExcludeFile', () => { | ||
it('should return true if the filename matches any of the exclude patterns', () => { | ||
const filename = 'src/components/Button.test.tsx'; | ||
const excludePatterns = ['**/node_modules/**', '**/dist/**', '**/*.test.*']; | ||
|
||
expect(shouldExcludeFile(filename, excludePatterns)).toBe(true); | ||
}); | ||
|
||
it('should return false if the filename does not match any of the exclude patterns', () => { | ||
const filename = 'src/components/Button.tsx'; | ||
const excludePatterns = ['**/node_modules/**', '**/dist/**']; | ||
|
||
expect(shouldExcludeFile(filename, excludePatterns)).toBe(false); | ||
}); | ||
|
||
it('should handle wildcard patterns correctly', () => { | ||
const filename = 'src/utils/helpers.ts'; | ||
const excludePatterns = ['**/node_modules/**', '**/dist/**', 'src/utils/*']; | ||
|
||
expect(shouldExcludeFile(filename, excludePatterns)).toBe(true); | ||
}); | ||
|
||
it('should handle empty exclude patterns', () => { | ||
const filename = 'src/components/Button.tsx'; | ||
const excludePatterns: string[] = []; | ||
|
||
expect(shouldExcludeFile(filename, excludePatterns)).toBe(false); | ||
}); | ||
|
||
test.each` | ||
filename | excludePatterns | expected | ||
${'src/components/Button.tsx'} | ${['**/node_modules/**', '**/dist/**', '**/*.tsx']} | ${true} | ||
${'src/utils/helpers.ts'} | ${['**/node_modules/**', '**/dist/**', 'src/utils/*']} | ${true} | ||
${'src/index.tsx'} | ${['**/node_modules/**', '**/dist/**', '**/*.test.*']} | ${false} | ||
${'src/tests/Button.test.tsx'} | ${['**/node_modules/**', '**/dist/**', '**/*.test.*']} | ${true} | ||
${'src/styles/global.css'} | ${[]} | ${false} | ||
`('should return $expected for filename $filename and excludePatterns $excludePatterns', ({ filename, excludePatterns, expected }) => { | ||
expect(shouldExcludeFile(filename, excludePatterns)).toBe(expected); | ||
}); | ||
}); |