Skip to content

Commit

Permalink
Merge pull request #93 from AthennaIO/develop
Browse files Browse the repository at this point in the history
Add debuglog and fix annotation types
  • Loading branch information
jlenon7 authored Jun 29, 2023
2 parents fbd78f7 + 876774d commit 527501b
Show file tree
Hide file tree
Showing 47 changed files with 732 additions and 612 deletions.
6 changes: 3 additions & 3 deletions bin/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
* file that was distributed with this source code.
*/

import { Runner, assert, specReporter } from '#src'
import { Runner } from '#src'

await Runner.setTsEnv()
.addPlugin(assert())
.addReporter(specReporter())
.addAssertPlugin()
.addSpecReporter()
.addPath('tests/unit/**/*Test.ts')
.setCliArgs(process.argv.slice(2))
.setGlobalTimeout(10000)
Expand Down
678 changes: 348 additions & 330 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/test",
"version": "4.1.0",
"version": "4.2.0",
"description": "The Athenna test runner. Built on top of Japa.",
"license": "MIT",
"author": "João Lenon <lenon@athenna.io>",
Expand Down Expand Up @@ -44,23 +44,24 @@
"#src/*": "./src/*.js",
"#src": "./src/index.js",
"#src/types": "./src/types/index.js",
"#src/debug": "./src/debug/index.js",
"#tests/*": "./tests/*.js",
"#tests": "./tests/index.js"
},
"dependencies": {
"@japa/assert": "^1.3.6",
"@japa/assert": "^1.4.1",
"@japa/run-failed-tests": "^1.1.0",
"@japa/runner": "^2.2.2",
"@japa/spec-reporter": "^1.3.2",
"@types/sinon": "^10.0.13",
"sinon": "^15.0.1"
"@japa/spec-reporter": "^1.3.3",
"@types/sinon": "^10.0.15",
"sinon": "^15.1.0"
},
"devDependencies": {
"@athenna/common": "^3.6.0",
"@athenna/common": "^4.2.0",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"c8": "^5.0.2",
"commitizen": "^4.2.6",
"commitizen": "^4.3.0",
"cross-env": "^7.0.3",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.36.0",
Expand Down
4 changes: 2 additions & 2 deletions src/decorators/AfterAll.ts → src/annotations/AfterAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import 'reflect-metadata'

import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'

/**
* Create a new after all (teardown) hook.
Expand All @@ -18,7 +18,7 @@ export function AfterAll(): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const afterAllHooks = Reflect.getMetadata('hooks:afterAll', Target)

Expand Down
4 changes: 2 additions & 2 deletions src/decorators/AfterEach.ts → src/annotations/AfterEach.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import 'reflect-metadata'

import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'

/**
* Create a new after each (teardown.each) hook.
Expand All @@ -18,7 +18,7 @@ export function AfterEach(): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const afterEachHooks = Reflect.getMetadata('hooks:afterEach', Target)

Expand Down
4 changes: 2 additions & 2 deletions src/decorators/BeforeAll.ts → src/annotations/BeforeAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import 'reflect-metadata'

import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'

/**
* Create a new before all (setup) hook.
Expand All @@ -18,7 +18,7 @@ export function BeforeAll(): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const beforeAllHooks = Reflect.getMetadata('hooks:beforeAll', Target)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import 'reflect-metadata'

import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'

/**
* Create a new before each (setup.each) hook.
Expand All @@ -18,7 +18,7 @@ export function BeforeEach(): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const beforeEachHooks = Reflect.getMetadata('hooks:beforeEach', Target)

Expand Down
6 changes: 3 additions & 3 deletions src/decorators/Cleanup.ts → src/annotations/Cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import 'reflect-metadata'

import type { Context, CleanupHandler } from '#src/types'
import { ObjectBuilder } from '@athenna/common'
import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'
import type { Context, CleanupHandler } from '#src/types'

/**
* Register a cleanup hook from within the test.
Expand All @@ -20,7 +20,7 @@ export function Cleanup(handler: CleanupHandler<Context>): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const tests: ObjectBuilder = Reflect.getMetadata('tests', Target)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import 'reflect-metadata'

import { ObjectBuilder } from '@athenna/common'
import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'

/**
* Disable test timeout. It is the same as calling `test.timeout(0)`
Expand All @@ -19,7 +19,7 @@ export function DisableTimeout(): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const tests: ObjectBuilder = Reflect.getMetadata('tests', Target)

Expand Down
4 changes: 2 additions & 2 deletions src/decorators/Fails.ts → src/annotations/Fails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import 'reflect-metadata'

import { ObjectBuilder } from '@athenna/common'
import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'

/**
* Expect the test to fail. Helpful in creating test cases to
Expand All @@ -20,7 +20,7 @@ export function Fails(): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const tests: ObjectBuilder = Reflect.getMetadata('tests', Target)

Expand Down
4 changes: 2 additions & 2 deletions src/decorators/Pin.ts → src/annotations/Pin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import 'reflect-metadata'

import { ObjectBuilder } from '@athenna/common'
import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'

/**
* Pin the test. If one test is pinned, Japa will run only pinned tests.
Expand All @@ -19,7 +19,7 @@ export function Pin(): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const tests: ObjectBuilder = Reflect.getMetadata('tests', Target)

Expand Down
4 changes: 2 additions & 2 deletions src/decorators/Retry.ts → src/annotations/Retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import 'reflect-metadata'

import { ObjectBuilder } from '@athenna/common'
import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'

/**
* Configure the number of times this test should be retried when failing.
Expand All @@ -19,7 +19,7 @@ export function Retry(times: number): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const tests: ObjectBuilder = Reflect.getMetadata('tests', Target)

Expand Down
6 changes: 3 additions & 3 deletions src/decorators/Setup.ts → src/annotations/Setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import 'reflect-metadata'

import type { Context, SetupHandler } from '#src/types'
import { ObjectBuilder } from '@athenna/common'
import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'
import type { Context, SetupHandler } from '#src/types'

/**
* Register a setup hook from within the test.
Expand All @@ -20,7 +20,7 @@ export function Setup(handler: SetupHandler<Context>): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const tests: ObjectBuilder = Reflect.getMetadata('tests', Target)

Expand Down
4 changes: 2 additions & 2 deletions src/decorators/Skip.ts → src/annotations/Skip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import 'reflect-metadata'

import { ObjectBuilder } from '@athenna/common'
import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'

/**
* Skip the test conditionally.
Expand All @@ -19,7 +19,7 @@ export function Skip(reason?: string): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const tests: ObjectBuilder = Reflect.getMetadata('tests', Target)

Expand Down
4 changes: 2 additions & 2 deletions src/decorators/Tags.ts → src/annotations/Tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import 'reflect-metadata'

import { ObjectBuilder } from '@athenna/common'
import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'

/**
* Assign tags to the test. Later you can use the tags to run specific tests.
Expand All @@ -19,7 +19,7 @@ export function Tags(tags: string[]): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const tests: ObjectBuilder = Reflect.getMetadata('tests', Target)

Expand Down
6 changes: 3 additions & 3 deletions src/decorators/Teardown.ts → src/annotations/Teardown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import 'reflect-metadata'

import type { Context, TeardownHandler } from '#src/types'
import { ObjectBuilder } from '@athenna/common'
import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'
import type { Context, TeardownHandler } from '#src/types'

/**
* Register a teardown hook from within the test.
Expand All @@ -20,7 +20,7 @@ export function Teardown(handler: TeardownHandler<Context>): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const tests: ObjectBuilder = Reflect.getMetadata('tests', Target)

Expand Down
4 changes: 2 additions & 2 deletions src/decorators/Test.ts → src/annotations/Test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import 'reflect-metadata'

import { ObjectBuilder } from '@athenna/common'
import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'

/**
* Create a new test.
Expand All @@ -19,7 +19,7 @@ export function Test(title?: string): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const tests: ObjectBuilder = Reflect.getMetadata('tests', Target)

Expand Down
4 changes: 2 additions & 2 deletions src/decorators/TestCase.ts → src/annotations/TestCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import 'reflect-metadata'

import { ObjectBuilder } from '@athenna/common'
import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'

/**
* Define the dataset for the test case. The test executor will be invoked
Expand All @@ -20,7 +20,7 @@ export function TestCase(value: any): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const tests: ObjectBuilder = Reflect.getMetadata('tests', Target)
const cases = tests.get(`${property}.with`, [])
Expand Down
4 changes: 2 additions & 2 deletions src/decorators/Timeout.ts → src/annotations/Timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import 'reflect-metadata'

import { ObjectBuilder } from '@athenna/common'
import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'

/**
* Set the test timeout.
Expand All @@ -19,7 +19,7 @@ export function Timeout(timeout: number): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const tests: ObjectBuilder = Reflect.getMetadata('tests', Target)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import 'reflect-metadata'

import { ObjectBuilder } from '@athenna/common'
import { Decorator } from '#src/helpers/Decorator'
import { Annotation } from '#src/helpers/Annotation'

/**
* Wait for the test executor to call done method.
Expand All @@ -19,7 +19,7 @@ export function WaitForDone(): MethodDecorator {
return (target: any, property: string, _: any) => {
const Target = target.constructor

Decorator.defineDefaultMetadata(Target)
Annotation.defineDefaultMetadata(Target)

const tests: ObjectBuilder = Reflect.getMetadata('tests', Target)

Expand Down
Loading

0 comments on commit 527501b

Please sign in to comment.