Changeset View
Changeset View
Standalone View
Standalone View
cypress/plugins/index.js
// *********************************************************** | /** | ||||
// This example plugins/index.js can be used to load plugins | * Copyright (C) 2019 The Software Heritage developers | ||||
// | * See the AUTHORS file at the top-level directory of this distribution | ||||
// You can change the location of this file or turn off loading | * License: GNU Affero General Public License version 3, or any later version | ||||
// the plugins file with the 'pluginsFile' configuration option. | * See top-level LICENSE file for more information | ||||
// | */ | ||||
// You can read more here: | |||||
// https://on.cypress.io/plugins-guide | |||||
// *********************************************************** | |||||
// This function is called when a project is opened or re-opened (e.g. due to | const axios = require('axios'); | ||||
// the project's config changing) | const fs = require('fs'); | ||||
module.exports = (on, config) => { | module.exports = (on, config) => { | ||||
// `on` is used to hook into various events Cypress emits | // produce JSON files prior launching browser in order to dynamically generate tests | ||||
// `config` is the resolved Cypress config | on('before:browser:launch', function(browser = {}, args) { | ||||
return new Promise((resolve) => { | |||||
let p1 = axios.get(`${config.baseUrl}/tests/data/content/code/extensions/`); | |||||
let p2 = axios.get(`${config.baseUrl}/tests/data/content/code/filenames/`); | |||||
Promise.all([p1, p2]) | |||||
.then(function(responses) { | |||||
fs.writeFileSync('cypress/fixtures/source-file-extensions.json', JSON.stringify(responses[0].data)); | |||||
fs.writeFileSync('cypress/fixtures/source-file-names.json', JSON.stringify(responses[1].data)); | |||||
resolve(args); | |||||
}); | |||||
}); | |||||
}); | |||||
}; | }; |