-
Notifications
You must be signed in to change notification settings - Fork 1.5k
finish #1536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
finish #1536
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: Test | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ master ] | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| matrix: | ||
| node-version: [20.x] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v1 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| - run: npm install | ||
| - run: npm start & sleep 5 && npm test | ||
| - name: Upload tests report(cypress mochaawesome merged HTML report) | ||
| if: ${{ always() }} | ||
| uses: actions/upload-artifact@v2 | ||
| with: | ||
| name: report | ||
| path: reports |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,32 @@ | ||
| 'use strict'; | ||
|
|
||
| // write your code here | ||
| const logo = document.querySelector('.logo'); | ||
|
|
||
| const promise1 = new Promise((resolve) => { | ||
| logo.addEventListener('click', () => { | ||
| resolve('Promise was resolved!'); | ||
| }); | ||
| }); | ||
|
|
||
| const promise2 = new Promise((resolve, reject) => { | ||
| setTimeout(() => { | ||
| reject(new Error(`Promise was rejected!`)); | ||
| }, 3000); | ||
| }); | ||
|
|
||
| promise1.then((message) => { | ||
| const div = document.createElement('div'); | ||
|
|
||
| div.classList.add('message'); | ||
| div.textContent = message; | ||
| document.body.appendChild(div); | ||
| }); | ||
|
|
||
| promise2.catch((message) => { | ||
| const div = document.createElement('div'); | ||
|
|
||
| div.classList.add('message', 'error-message'); | ||
| div.textContent = message; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reject() call passes an Error object, but setting div.textContent = message will display '[object Object]' instead of the error text. Use message.message or message.toString() to get the actual error text. |
||
| document.body.appendChild(div); | ||
|
Comment on lines
+12
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. promise2 needs a .then() success handler in addition to .catch(). Even though promise2 rejects, it still requires a success handler per the 'both promises' requirement. |
||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requirement #4 states handlers should be added for 'both promises'. Currently promise1 only has .then() but no .catch() handler. Add promise1.catch() with the same error div creation logic.