Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
const url = require('url');
const http = require('http');
const { setWorldConstructor, After, AfterAll, Before, BeforeAll, Given, When, Then } = require('cucumber');
const { registerHooks, World: BaseWorld, registerSteps } = require('../../../src/index');
class World extends BaseWorld {
constructor() {
super();
}
}
setWorldConstructor(World);
registerHooks({ After, AfterAll, Before, BeforeAll });
registerSteps({ Given, Then, When });
process.env.GRAPHQL_BASE_URL = 'http://localhost:3000/graphql';
// a custom login step
Given('I am logged in as a {string}', async function (role) {
// does an agent for this role already exist?
const roleAgent = this.getAgentByRole(role);
if (roleAgent) {
this.setAgentByRole(role, roleAgent);
return;
}
// construct and send a login request
const agent = this.newAgent();
return {
headers,
body: await res.json(),
}
},
method,
url,
)
// Store response for further assertions
this.response = response
}
}
setWorldConstructor(World)
const { setWorldConstructor, BeforeAll, Before, After, AfterAll } = require('cucumber');
const World = require('./World');
setWorldConstructor(World);
if (process.argv.some((arg) => arg === 'test/features/hook.feature')) {
BeforeAll(() => { console.log('BeforeAll'); });
AfterAll(() => { console.log('AfterAll'); });
}
Before('@before', () => { console.log('Before'); });
After('@after', () => { console.log('After'); });
this.jwt = null;
this.rights = null;
this.previousJwt = null;
this.content = null;
this.error = null;
this.notifications = [];
this.callback = notification => {
this.notifications.push(notification);
};
}
}
setWorldConstructor(World);
import { setDefaultTimeout, setWorldConstructor } from 'cucumber';
import Factory from '../pages/Factory';
setDefaultTimeout(60 * 1000);
class World {
constructor(args) {
this.browser = args.parameters.browser;
this.local = args.parameters.local;
this.display = args.parameters.display;
this.pageFactory = new Factory(this);
this.host = 'http://app.local:3000';
}
}
setWorldConstructor(World);