Remove dev dep imports in production code (#2937)

Fixes #2876 with @paulmelnikow's suggestion 

Moved imports of `ServiceTester` and `createServiceTester` to a separate file so that dev dependencies are not imported by service classes.
This commit is contained in:
Caleb Cartwright
2019-02-05 20:51:55 -06:00
committed by Paul Melnikow
parent cdeba2fdf9
commit 855c9cd261
220 changed files with 229 additions and 224 deletions

View File

@@ -43,7 +43,7 @@ Locate the test file(s) for the service, which can be found in `*.tester.js` fil
With `DeprecatedService` classes we cannot use `createServiceTester()` so you will need to create the `ServiceTester` class directly. For example:
```js
const { ServiceTester } = require('..')
const { ServiceTester } = require('../tester')
const t = (module.exports = new ServiceTester({
id: 'imagelayers',
@@ -69,7 +69,7 @@ Here is an example of what the final result would look like for a test file:
```js
'use strict'
const { ServiceTester } = require('..')
const { ServiceTester } = require('../tester')
const t = (module.exports = new ServiceTester({
id: 'imagelayers',

View File

@@ -278,7 +278,7 @@ https://github.com/hapijs/joi/blob/master/API.md
Switch to `createServiceTester`:
```js
const t = (module.exports = require('..').createServiceTester())
const t = (module.exports = require('../tester').createServiceTester())
```
This may require updating the URLs, which will be relative to the service's base

View File

@@ -37,14 +37,14 @@ We'll start by adding some boilerplate to our file:
const Joi = require('joi')
const t = (module.exports = require('..').createServiceTester())
const t = (module.exports = require('../tester').createServiceTester())
```
1. Import [Joi][] We'll use this to make assertions. This is the same library
we use to define schema for validation in the main badge class.
2. If our `.service.js` module exports a single class, we can
`require('..').createServiceTester()`, which uses convention to create a
`require('../tester').createServiceTester()`, which uses convention to create a
`ServiceTester` object. Calling this inside
`services/wercker/wercker.tester.js` will create a `ServiceTester` object
configured for the service exported in `services/wercker/wercker.service.js`.