This repository has been archived by the owner on Feb 27, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(instructions): add instructions files
- Loading branch information
1 parent
e35ce97
commit fcd733c
Showing
5 changed files
with
163 additions
and
4 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
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,31 @@ | ||
'use strict' | ||
|
||
/* | ||
* adonis-vow | ||
* | ||
* (c) Harminder Virk <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
const path = require('path') | ||
|
||
module.exports = async (cli) => { | ||
try { | ||
const appRoot = cli.helpers.appRoot() | ||
/** | ||
* Copy vow file | ||
*/ | ||
await cli.copy(path.join(__dirname, 'templates/vowfile.js'), path.join(appRoot, 'vowfile.js')) | ||
cli.command.completed('create', 'vowfile.js') | ||
|
||
/** | ||
* Copy example test case | ||
*/ | ||
await cli.copy(path.join(__dirname, 'templates/unitTest.js'), path.join(appRoot, 'test/unit/example.spec.js')) | ||
cli.command.completed('create', 'test/unit/example.spec.js') | ||
} catch (error) { | ||
// ignore the error | ||
} | ||
} |
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,27 @@ | ||
## Register provider | ||
|
||
The provider must be registered as an `aceProvider`, since there is no point in loading test runner when running your app. | ||
|
||
|
||
```js | ||
const aceProviders = [ | ||
'@adonisjs/providers/VowProvider' | ||
] | ||
``` | ||
|
||
## Run tests | ||
That's all you really need to do in order to get up and running. Now you can run tests by executing following command. | ||
|
||
```bash | ||
adonis test | ||
``` | ||
|
||
For help, run | ||
|
||
```bash | ||
adonis test --help | ||
``` | ||
|
||
## Envrionment files | ||
|
||
The vow provider attempts to load the `.env.test` file when running tests. Any variables placed inside this file will override the actual variables. |
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,7 @@ | ||
'use strict' | ||
|
||
const { test } = use('Test/Suite')('Example test suite') | ||
|
||
test('dummy test to learn to test 2 + 2', ({ assert }) => { | ||
assert.equal(2 + 2, 4) | ||
}) |
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,62 @@ | ||
'use strict' | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Vow file | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The vow file is loaded before running your tests. This is the best place | ||
| to hook operations `before` and `after` running the tests. | ||
| | ||
*/ | ||
|
||
// Uncomment when want to run migrations | ||
// const ace = require('@adonisjs/ace') | ||
|
||
module.exports = (cli, runner) => { | ||
runner.before(() => { | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Start the server | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Starts the http server before running the tests. You can comment this | ||
| line, if http server is not required | ||
| | ||
*/ | ||
use('Adonis/Src/Server').listen() | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Run migrations | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Migrate the database before starting the tests. | ||
| | ||
*/ | ||
// await ace.call('migration:run') | ||
}) | ||
|
||
runner.after(() => { | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Shutdown server | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Shutdown the HTTP server when all tests have been executed. | ||
| | ||
*/ | ||
use('Adonis/Src/Server').getInstance().close() | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Rollback migrations | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Once all tests have been completed, we should reset the database to it's | ||
| original state | ||
| | ||
*/ | ||
// await ace.call('migration:reset') | ||
}) | ||
} |