Skip to content

Commit

Permalink
Merge branch 'release/1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
DominusKelvin committed Jul 29, 2023
2 parents 17b00f0 + ed92e75 commit 667a499
Show file tree
Hide file tree
Showing 8 changed files with 5,493 additions and 6,704 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Prettier

on: [push, pull_request]

jobs:
prettier:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Run npm ci
run: npm ci

- name: Run Prettier
run: npx prettier --write .
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] }
87 changes: 47 additions & 40 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,59 @@ const { assert } = require('@japa/assert')
const { apiClient } = require('@japa/api-client')
const { specReporter } = require('@japa/spec-reporter')
const { runFailedTests } = require('@japa/run-failed-tests')

const { browserClient } = require('@japa/browser-client')

function presetSails() {
return async function(config, runner, { TestContext }) {
runner.onSuite((suite) => {
suite.setup(async () => {
if (suite.name === 'functional') {
const sails = await startApp({ environment: 'test' })
TestContext.macro('route', function(target, routeParams) {
let url = sails.getUrlFor(target)
if (routeParams) {
url = interpolateUrl(url, routeParams)
function interpolateUrl(url, replaceMap) {
return url.split('/').map(
(part) => part.startsWith(':') ? replaceMap[part.substr(1)] : part
).join('/')
}
}
return url
})
return async () => await sails.lower()
}
await startApp({ environment: 'test' }, 'load')

})
})
}
return async function (config, runner, { TestContext }) {
runner.onSuite((suite) => {
suite.setup(async () => {
if (
suite.name == 'functional' ||
suite.name == 'e2e' ||
suite.name == 'browser'
) {
const sails = await startApp({ environment: 'test' })
TestContext.macro('route', function (target, routeParams) {
let url = sails.getUrlFor(target)
if (routeParams) {
url = interpolateUrl(url, routeParams)
function interpolateUrl(url, replaceMap) {
return url
.split('/')
.map((part) =>
part.startsWith(':') ? replaceMap[part.substr(1)] : part
)
.join('/')
}
}
return url
})
return async () => await sails.lower()
}
await startApp({ environment: 'test' }, 'load')
})
})
}
}

function startApp(options, method = 'lift') {
return new Promise((resolve, reject) => {
const Sails = require('sails').constructor;
const sails = new Sails();
sails[method](options, (error, sails) => {
if (error) {
reject(error)
} else {
resolve(sails)
}
})
return new Promise((resolve, reject) => {
const Sails = require('sails').constructor
const sails = new Sails()
sails[method](options, (error, sails) => {
if (error) {
reject(error)
} else {
resolve(sails)
}
})
})
}
module.exports = {
presetSails,
assert,
apiClient,
specReporter,
runFailedTests
presetSails,
assert,
apiClient,
browserClient,
specReporter,
runFailedTests
}
Loading

0 comments on commit 667a499

Please sign in to comment.