2020-09-14 14:48:44 +02:00
|
|
|
const locations = {
|
|
|
|
index:
|
2021-08-14 03:57:13 +01:00
|
|
|
'learn/back-end-development-and-apis/managing-packages-with-npm/' +
|
2020-09-14 14:48:44 +02:00
|
|
|
'how-to-use-package-json-the-core-of-any-node-js-project-or-npm-package'
|
|
|
|
};
|
|
|
|
|
|
|
|
const selectors = {
|
|
|
|
defaultOutput: '.output-text',
|
|
|
|
input: 'input[name="solution"]'
|
|
|
|
};
|
|
|
|
|
|
|
|
const unhandledErrorMessage = 'Something is not quite right';
|
|
|
|
const runningOutput = '// running tests';
|
|
|
|
const finishedOutput = '// tests completed';
|
|
|
|
|
2021-03-11 00:31:46 +05:30
|
|
|
describe('Backend challenge', function () {
|
2020-09-14 14:48:44 +02:00
|
|
|
it('renders', () => {
|
|
|
|
cy.visit(locations.index);
|
|
|
|
|
|
|
|
cy.title().should(
|
|
|
|
'eq',
|
2021-12-01 07:53:37 -08:00
|
|
|
'Managing Packages with NPM - How to Use package.json, the Core of Any' +
|
2020-09-14 14:48:44 +02:00
|
|
|
' Node.js Project or npm Package | Learn | freeCodeCamp.org'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not generate unhandled errors on submission', () => {
|
|
|
|
cy.visit(locations.index);
|
2022-04-01 00:07:01 -05:00
|
|
|
cy.get(selectors.input).type('https://example.com');
|
|
|
|
|
|
|
|
// temporary fix until https://github.com/cypress-io/cypress/issues/20562 is fixed
|
|
|
|
cy.contains(`I've completed this challenge`)
|
|
|
|
.click()
|
|
|
|
|
|
|
|
// revert to this when it is
|
|
|
|
// .type('{enter}')
|
|
|
|
|
2020-09-14 14:48:44 +02:00
|
|
|
.then(() => {
|
|
|
|
cy.get(selectors.defaultOutput)
|
|
|
|
.contains(runningOutput)
|
|
|
|
.contains(finishedOutput);
|
|
|
|
cy.contains(unhandledErrorMessage).should('not.exist');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|