From 817206ab8a8708c7d78c97a2d34ce52925fc69fb Mon Sep 17 00:00:00 2001 From: u013235949 Date: Thu, 5 Sep 2024 13:34:00 +0800 Subject: [PATCH] Thu Sep 5 13:34:00 CST 2024 inscode --- .inscode | 8 ++++++-- babel.config.js | 3 +++ index.js | 4 +++- index.test.js | 5 +++++ package.json | 17 +++++++++++------ 5 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 babel.config.js create mode 100644 index.test.js diff --git a/.inscode b/.inscode index ecc8bdd..c569fd6 100644 --- a/.inscode +++ b/.inscode @@ -1,6 +1,10 @@ -run = "npm i && npm run dev" +run = "npm i && npm run test" +language = "node" [env] PATH = "/root/${PROJECT_DIR}/.config/npm/node_global/bin:/root/${PROJECT_DIR}/node_modules/.bin:${PATH}" XDG_CONFIG_HOME = "/root/.config" -npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/node_global" \ No newline at end of file +npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/node_global" + +[debugger] +program = "main.js" diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000..32b35df --- /dev/null +++ b/babel.config.js @@ -0,0 +1,3 @@ +module.exports = { + presets: [['@babel/preset-env', {targets: {node: 'current'}}]], +}; \ No newline at end of file diff --git a/index.js b/index.js index 2d7e683..3ad4c4a 100644 --- a/index.js +++ b/index.js @@ -1 +1,3 @@ -console.log("欢迎来到 InsCode"); \ No newline at end of file +export function sum(a, b) { + return a + b; +} \ No newline at end of file diff --git a/index.test.js b/index.test.js new file mode 100644 index 0000000..9dfe49b --- /dev/null +++ b/index.test.js @@ -0,0 +1,5 @@ +import { sum } from './index' + +test('adds 1 + 2 to equal 3', () => { + expect(sum(1, 2)).toBe(3); +}); \ No newline at end of file diff --git a/package.json b/package.json index 72caa17..8b3208c 100644 --- a/package.json +++ b/package.json @@ -4,15 +4,20 @@ "description": "", "main": "index.js", "scripts": { - "dev": "node index.js", - "test": "echo \"Error: no test specified\" && exit 1" + "dev": "node index.js", + "test": "jest" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { - "@types/node": "^18.0.6", - "node-fetch": "^3.2.6" + "@types/node": "^18.0.6", + "node-fetch": "^3.2.6" + }, + "devDependencies": { + "@babel/core": "^7.25.2", + "@babel/preset-env": "^7.25.4", + "babel-jest": "^29.7.0", + "jest": "^29.7.0" } - } - \ No newline at end of file +} -- GitLab