diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3c98baf21..576dc387d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,13 +54,12 @@ Windows: npm install -g windows-build-tools ``` - #### lerna n8n is split up in different modules which are all in a single mono repository. To facilitate those modules management, [lerna](https://lerna.js.org) gets used. It automatically sets up file-links between modules which depend on each -others. +other. So for the setup to work correctly lerna has to be installed globally like this: @@ -79,17 +78,17 @@ checked out and set up: git clone https://github.com/n8n-io/n8n.git ``` -2. Go into repository folder +1. Go into repository folder ``` cd n8n ``` -3. Install all dependencies of all modules and link them together: +1. Install all dependencies of all modules and link them together: ``` lerna bootstrap --hoist ``` -4. Build all the code: +1. Build all the code: ``` npm run build ``` @@ -103,3 +102,39 @@ To start n8n execute: ``` npm run start ``` + + +## Development Cycle + +While iterating on n8n modules code, you can run `npm run dev`. It will then +automatically build your code, restart the backend and refresh the frontend +(editor-ui) on every change you make. + +1. Start n8n in development mode: + ``` + npm run dev + ``` +1. hack, hack, hack +1. Check if everything still runs in production mode + ``` + npm run build + npm run start + ``` +1. Create tests +1. Run all tests + ``` + npm run test + ``` +1. Commit code and create pull request + + +### Test suite + +The tests can be started via: +``` +npm run test +``` + +If that gets executed in one of the package folders it will only run the tests +of this package. If it gets executed in the n8n-root folder it will run all +tests of all packages. diff --git a/package.json b/package.json index efb658e2e..f557ffb9f 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "build": "lerna exec npm run build", "dev": "lerna exec npm run dev --parallel", "start": "cd packages/cli && node dist/index.js start", + "test": "lerna run test", "watch": "lerna run --parallel watch" }, "devDependencies": { diff --git a/packages/cli/test/placeholder.test.ts b/packages/cli/test/placeholder.test.ts new file mode 100644 index 000000000..23ba06a64 --- /dev/null +++ b/packages/cli/test/placeholder.test.ts @@ -0,0 +1,7 @@ +describe('Placeholder', () => { + + test('example', () => { + expect(1 + 1).toEqual(2); + }); + +}); diff --git a/packages/editor-ui/package.json b/packages/editor-ui/package.json index 72da793cb..e13f0244d 100644 --- a/packages/editor-ui/package.json +++ b/packages/editor-ui/package.json @@ -16,6 +16,7 @@ "dev": "npm run serve", "lint": "vue-cli-service lint", "serve": "VUE_APP_URL_BASE_API=http://localhost:5678/ vue-cli-service serve", + "test": "npm run test:unit", "tslint": "tslint -p tsconfig.json -c tslint.json", "test:e2e": "vue-cli-service test:e2e", "test:unit": "vue-cli-service test:unit" diff --git a/packages/editor-ui/tests/unit/example.spec.ts b/packages/editor-ui/tests/unit/example.spec.ts deleted file mode 100644 index b8005575b..000000000 --- a/packages/editor-ui/tests/unit/example.spec.ts +++ /dev/null @@ -1,12 +0,0 @@ -// import { shallowMount } from '@vue/test-utils'; -// import HelloWorld from '@/components/HelloWorld.vue'; - -// describe('HelloWorld.vue', () => { -// it('renders props.msg when passed', () => { -// const msg = 'new message'; -// const wrapper = shallowMount(HelloWorld, { -// propsData: { msg } -// }); -// expect(wrapper.text()).toMatch(msg); -// }); -// }); diff --git a/packages/editor-ui/tests/unit/placeholder.spec.ts b/packages/editor-ui/tests/unit/placeholder.spec.ts new file mode 100644 index 000000000..21c4bf29e --- /dev/null +++ b/packages/editor-ui/tests/unit/placeholder.spec.ts @@ -0,0 +1,5 @@ +describe('Placeholder.vue', () => { + it('example', () => { + expect(1 + 1).toEqual(2); + }); +}); diff --git a/packages/node-dev/package.json b/packages/node-dev/package.json index bd3108726..b1ecdb2fa 100644 --- a/packages/node-dev/package.json +++ b/packages/node-dev/package.json @@ -16,6 +16,7 @@ "scripts": { "dev": "npm run watch", "build": "tsc", + "test": "jest", "tslint": "tslint -p tsconfig.json -c tslint.json", "watch": "tsc --watch" }, @@ -45,5 +46,23 @@ "replace-in-file": "^4.1.0", "typescript": "~3.5.2", "vorpal": "^1.12.0" + }, + "jest": { + "transform": { + "^.+\\.tsx?$": "ts-jest" + }, + "testURL": "http://localhost/", + "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", + "testPathIgnorePatterns": [ + "/dist/", + "/node_modules/" + ], + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "json", + "node" + ] } } diff --git a/packages/node-dev/test/placeholder.test.ts b/packages/node-dev/test/placeholder.test.ts new file mode 100644 index 000000000..23ba06a64 --- /dev/null +++ b/packages/node-dev/test/placeholder.test.ts @@ -0,0 +1,7 @@ +describe('Placeholder', () => { + + test('example', () => { + expect(1 + 1).toEqual(2); + }); + +}); diff --git a/packages/node-dev/tsconfig.json b/packages/node-dev/tsconfig.json index 97c769b1b..cfc2e2af1 100644 --- a/packages/node-dev/tsconfig.json +++ b/packages/node-dev/tsconfig.json @@ -4,7 +4,8 @@ "es2017" ], "types": [ - "node" + "node", + "jest" ], "module": "commonjs", "esModuleInterop": true, @@ -26,6 +27,7 @@ ], "exclude": [ "dist", + "node_modules/**/*", "**/*.spec.ts" ] } diff --git a/packages/nodes-base/test/placeholder.test.ts b/packages/nodes-base/test/placeholder.test.ts new file mode 100644 index 000000000..23ba06a64 --- /dev/null +++ b/packages/nodes-base/test/placeholder.test.ts @@ -0,0 +1,7 @@ +describe('Placeholder', () => { + + test('example', () => { + expect(1 + 1).toEqual(2); + }); + +});