Skip to content

Commit

Permalink
feat(sandbox-testing): add sandbox for testing
Browse files Browse the repository at this point in the history
Added a sandbox package to testing service components with a real LB4 application

BREAKING CHANGE:
Fixed binding errors in core sequence

SFO-20
  • Loading branch information
samarpan-b committed Jun 11, 2020
1 parent 69851b8 commit 296279c
Show file tree
Hide file tree
Showing 50 changed files with 7,385 additions and 96 deletions.
1 change: 1 addition & 0 deletions .cz-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = {
{name: 'notification-service'},
{name: 'scheduler-service'},
{name: 'video-conferencing-service'},
{name: 'sandbox-testing'},
],

appendBranchNameToCommitMessage: false,
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packages": ["packages/*", "services/*", "facades/*"],
"packages": ["packages/*", "services/*", "facades/*", "sandbox/*"],
"command": {
"bootstrap": {
"concurrency": 4,
Expand Down
1 change: 1 addition & 0 deletions packages/core/locales/es-co.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions packages/core/locales/es.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions packages/core/locales/pt-br.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions packages/core/locales/pt-pt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"node": ">=10"
},
"scripts": {
"build": "lb-tsc",
"build": "npm run clean && lb-tsc",
"build:watch": "lb-tsc --watch",
"lint": "npm run prettier:check && npm run eslint",
"lint:fix": "npm run eslint:fix && npm run prettier:fix",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/constants/globals.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const BINDING_PREFIX = 'sourcefuse.services.';
export const BINDING_PREFIX = 'sourceloop.services';
5 changes: 5 additions & 0 deletions sandbox/testing/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
npm-debug.log
/dist
# Cache used by TypeScript's incremental build
*.tsbuildinfo
3 changes: 3 additions & 0 deletions sandbox/testing/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
coverage/
3 changes: 3 additions & 0 deletions sandbox/testing/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: '@loopback/eslint-config',
};
64 changes: 64 additions & 0 deletions sandbox/testing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# Transpiled JavaScript files from Typescript
/dist

# Cache used by TypeScript's incremental build
*.tsbuildinfo
4 changes: 4 additions & 0 deletions sandbox/testing/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recursive": true,
"require": "source-map-support/register"
}
2 changes: 2 additions & 0 deletions sandbox/testing/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package-lock=true
scripts-prepend-node-path=true
2 changes: 2 additions & 0 deletions sandbox/testing/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
*.json
7 changes: 7 additions & 0 deletions sandbox/testing/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"bracketSpacing": false,
"singleQuote": true,
"printWidth": 80,
"trailingComma": "all",
"arrowParens": "avoid"
}
39 changes: 39 additions & 0 deletions sandbox/testing/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Sandbox Application",
"program": "${workspaceFolder}/dist/index.js",
"preLaunchTask": "Build Project"
},
{
"type": "node",
"request": "launch",
"name": "Mocha Sandbox Application",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"--timeout",
"999999",
"--colors",
"${workspaceFolder}/dist/__tests__"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"preLaunchTask": "Build Project"
},
{
"type": "node",
"request": "launch",
"name": "Mocha Current File",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": ["--timeout", "999999", "--colors", "${file}"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
32 changes: 32 additions & 0 deletions sandbox/testing/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"editor.rulers": [80],
"editor.tabCompletion": "on",
"editor.tabSize": 2,
"editor.trimAutoWhitespace": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll.eslint": true
},

"files.exclude": {
"**/.DS_Store": true,
"**/.git": true,
"**/.hg": true,
"**/.svn": true,
"**/CVS": true,
"dist": true,
},
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,

"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"typescript.preferences.quoteStyle": "single",
"eslint.run": "onSave",
"eslint.nodePath": "./node_modules",
"eslint.validate": [
"javascript",
"typescript"
]
}
43 changes: 43 additions & 0 deletions sandbox/testing/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Watch and Compile Project",
"type": "shell",
"command": "npm",
"args": ["--silent", "run", "build:watch"],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$tsc-watch"
},
{
"label": "Build Project",
"type": "shell",
"command": "npm",
"args": [
"run",
"build"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$tsc"
},
{
"label": "Build, Test and Lint",
"type": "shell",
"command": "npm",
"args": ["--silent", "run", "test:dev"],
"group": {
"kind": "test",
"isDefault": true
},
"problemMatcher": ["$tsc", "$eslint-compact", "$eslint-stylish"]
}
]
}
6 changes: 6 additions & 0 deletions sandbox/testing/.yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@loopback/cli": {
"version": "2.7.1",
"packageManager": "npm"
}
}
36 changes: 36 additions & 0 deletions sandbox/testing/DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Developer's Guide

We use Visual Studio Code for developing LoopBack and recommend the same to our
users.

## VSCode setup

Install the following extensions:

- [eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
- [prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)

## Development workflow

### Visual Studio Code

1. Start the build task (Cmd+Shift+B) to run TypeScript compiler in the
background, watching and recompiling files as you change them. Compilation
errors will be shown in the VSCode's "PROBLEMS" window.

2. Execute "Run Rest Task" from the Command Palette (Cmd+Shift+P) to re-run the
test suite and lint the code for both programming and style errors. Linting
errors will be shown in VSCode's "PROBLEMS" window. Failed tests are printed
to terminal output only.

### Other editors/IDEs

1. Open a new terminal window/tab and start the continuous build process via
`npm run build:watch`. It will run TypeScript compiler in watch mode,
recompiling files as you change them. Any compilation errors will be printed
to the terminal.

2. In your main terminal window/tab, run `npm run test:dev` to re-run the test
suite and lint the code for both programming and style errors. You should run
this command manually whenever you have new changes to test. Test failures
and linter errors will be printed to the terminal.
28 changes: 28 additions & 0 deletions sandbox/testing/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Check out https://hub.docker.com/_/node to select a new base image
FROM node:10-slim

# Set to a non-root built-in user `node`
USER node

# Create app directory (with user `node`)
RUN mkdir -p /home/node/app

WORKDIR /home/node/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY --chown=node package*.json ./

RUN npm install

# Bundle app source code
COPY --chown=node . .

RUN npm run build

# Bind to all network interfaces so that it can be mapped to the host OS
ENV HOST=0.0.0.0 PORT=3000

EXPOSE ${PORT}
CMD [ "node", "." ]
3 changes: 3 additions & 0 deletions sandbox/testing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# testing

[![LoopBack](https://github.com/strongloop/loopback-next/raw/master/docs/site/imgs/branding/Powered-by-LoopBack-Badge-(blue)[email protected])](http://loopback.io/)
Loading

0 comments on commit 296279c

Please sign in to comment.