Skip to content

Commit

Permalink
Merge pull request #61 from AthennaIO/develop
Browse files Browse the repository at this point in the history
Use @athenna/test
  • Loading branch information
jlenon7 authored Mar 10, 2023
2 parents 0ed0897 + 581298f commit f1f9968
Show file tree
Hide file tree
Showing 21 changed files with 338 additions and 297 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ jobs:

- name: Run tests
run: npm run test:coverage
env:
SLACK_URL: ${{ secrets.SLACK_URL }}
DISCORD_URL: ${{ secrets.DISCORD_URL }}
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}

- name: Test code transpilation
run: npm run build
Expand Down
15 changes: 3 additions & 12 deletions bin/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ const path = Path.nodeModules('@athenna/tsconfig.build.json')
| Create the tsconfig file for building the project.
*/

const tsconfig = JSON.parse(
new File('../tsconfig.json').getContentSync().toString(),
)
const tsconfig = await new File('../tsconfig.json').getContentAsJson()

delete tsconfig['ts-node']

Expand All @@ -39,8 +37,6 @@ tsconfig.compilerOptions.outDir = '../../build'
tsconfig.include = ['../../src']
tsconfig.exclude = ['../../bin', '../../node_modules', '../../tests']

const tsconfigBuild = JSON.stringify(tsconfig)

/*
|--------------------------------------------------------------------------
| Compilation
Expand All @@ -50,12 +46,7 @@ const tsconfigBuild = JSON.stringify(tsconfig)
| compilation and deleting the tsconfig file generated.
*/

const file = new File(path, Buffer.from(tsconfigBuild))

if (file.fileExists) {
await file.remove()
}

await file.load()
const file = new File(path, '')
await file.setContent(JSON.stringify(tsconfig))
await Exec.command(`rimraf ../build && tsc --project ${path}`)
await file.remove()
35 changes: 2 additions & 33 deletions bin/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,11 @@

import { assert } from '@japa/assert'
import { Path } from '@athenna/common'
import { pathToFileURL } from 'node:url'
import { Importer } from '@athenna/test'
import { EnvHelper } from '@athenna/config'
import { specReporter } from '@japa/spec-reporter'
import { configure, processCliArgs, run } from '@japa/runner'

/*
|--------------------------------------------------------------------------
| Japa types
|--------------------------------------------------------------------------
|
| Declare customized japa types.
*/

declare module '@japa/assert' {
export interface Assert {
throws(fn: () => any, errType: any, message?: string): void
doesNotThrows(fn: () => any, errType: any, message?: string): void
rejects(
fn: () => any | Promise<any>,
errType: any,
message?: string,
): Promise<any>
doesNotRejects(
fn: () => any | Promise<any>,
errType: any,
message?: string,
): Promise<any>
}
}

declare module '@japa/runner' {
interface TestContext {
assert: import('@japa/assert').Assert
}
}

/*
|--------------------------------------------------------------------------
| Set IS_TS env.
Expand Down Expand Up @@ -86,7 +55,7 @@ configure({
files: ['tests/**/*Test.ts'],
plugins: [assert()],
reporters: [specReporter()],
importer: filePath => import(pathToFileURL(filePath).href),
importer: Importer.import,
timeout: 5000,
},
})
Expand Down
Loading

0 comments on commit f1f9968

Please sign in to comment.