Ghost/test/utils/test-agent.js
Naz fd0a3e80ae Removed @tryghost/jest-snapshot dependency
refs https://github.com/TryGhost/Toolbox/issues/215

- Ghost tests had difficulty running sometimes when the versions for jest-snapshot package did not match in Ghost and @tryghost/express-test
- This is the error that was showing up: `IncorrectUsageError: Unable to run snapshot tests, current test was not configured`
- The reason why snapshot tests were misconfigured was multiple instances of SnapshotManager, which broke the singleton pattern
- Having jest-snapshot embeded within express-test makes sure the versions stay the same across the clients
- The version bump also introduces passing "queryParams" parameter into the Agent constructor - enables configuring query parameters that would appear in each agent's request. Example usecase - Content API authentication parameter "key" would be nice to "remember" and add to every request URL
2022-02-22 09:41:58 +07:00

24 lines
585 B
JavaScript

const Agent = require('@tryghost/express-test');
/**
* @constructor
* @param {Object} app Ghost express app instance
* @param {Object} options
* @param {String} options.apiURL
* @param {String} options.originURL
*/
class TestAgent extends Agent {
constructor(app, options) {
super(app, {
baseUrl: options.apiURL,
headers: {
host: options.originURL.replace(/http:\/\//, ''),
origin: options.originURL
},
queryParams: options.queryParams
});
}
}
module.exports = TestAgent;