Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: test

on:
push:
branches: [master]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- run: npm test
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@

---

#### Troubleshooting

- If you catch error like [this](https://user-images.githubusercontent.com/17920285/158375305-f54d87fa-6f42-402f-af25-10b233d98cf9.png) you can try to make `npm install -g node-gyp`

---

#### Submit to [rs app](https://app.rs.school)

1. Open [rs app](https://app.rs.school) and login
Expand All @@ -31,7 +25,7 @@

#### Notes

1. We recommend you to use Node.js of version 16.x.x LTS. If you use any of features, that does not supported by Node.js v16, there may be problems with task submit.
1. We recommend you to use Node.js of version 22.x.x LTS (the minimum required version, see `engines` in `package.json`). If you use any features that are not supported by Node.js v22, there may be problems with task submit.
2. Please, be sure that each of your tests is limited to 30 sec.

---
Expand Down
8 changes: 4 additions & 4 deletions lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const isThrowingExpectedErrors = function (testsFuncs, expectedErrMsg) {
f();
} catch (err) {
if (isNotImplementedError(err)) {
this.skip();
this.todo();
} else if (err.message !== expectedErrMsg) {
return INCORRECT_RESULT_MSG;
}
Expand All @@ -22,7 +22,7 @@ const isNotThrowingErrors = function (testFuncs) {
f();
} catch (err) {
if (isNotImplementedError(err)) {
this.skip();
this.todo();
} else {
return INCORRECT_RESULT_MSG;
}
Expand All @@ -35,8 +35,8 @@ const isNotThrowingErrors = function (testFuncs) {
const isNotImplementedError = (err) => err instanceof NotImplementedError;

class NotImplementedError extends Error {
constructor() {
super('Not implemented');
constructor(message = 'Not implemented') {
super(message);
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ module.exports = {
isThrowingExpectedErrors,
isNotImplementedError,
test,
NotImplementedError,
};
9 changes: 3 additions & 6 deletions lib/optional-test-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ const { isNotImplementedError } = require('./errors.js');
function optionalTestExtension(title, cb, isAsyncTest) {
test(title, (t) => {
if (isAsyncTest) {
runAsyncTestCb(cb, t, title);
} else {
runSyncTestCb(cb, t, title);
return runAsyncTestCb(cb, t, title);
}
return runSyncTestCb(cb, t, title);
});
}

const runAsyncTestCb = (cb, t, title) => {
const runAsyncTestCb = (cb, t, title) =>
cb.call(t).catch((err) => {
handleTestError(t, title, err);
});
};

const runSyncTestCb = (cb, t, title) => {
try {
Expand All @@ -26,7 +24,6 @@ const runSyncTestCb = (cb, t, title) => {
};

const handleTestError = (t, title, err) => {
console.log('ERROR',err);
if (isNotImplementedError(err)) {
t.todo(`Pending: ${title}`);
} else {
Expand Down
Loading
Loading