diff --git a/README.md b/README.md index 17768fa..177d62e 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,60 @@ -This will bundle a simple typescript app with third party dependencies into a single javascript library for browsers (ie, can be consumed by a script tag). +## README + +This is an example of a typescript app that is compiled down to a single js file for consumption in a browser. + +## Technologies used +* typescript +* karma +* jasmine +* rollup (for bundling) + ## How to use -`npm install` +`npm install` // installs -`npm run build` +`npm run build` // bundles Output will be created in `dist/bundle.js` -Load `test/index.html` in browser and check console logs. +Load `test/index.html` in browser. + +All exported classes are available under the namespace specified in +rollup.config.js -> output.name value (MyNamespace here) + +## Unit testing + +### Prerequisit + +Chrome installed on machine + +### Running + +`./node_modules/karma/bin/karma start` + +Runs tests without debugging. +Uses ChromeHeadless (ie, no browser will open). + +### Debugging + +Step 1 +`./node_modules/karma/bin/karma start --no-single-run --browser=Chrome` + +Step 2 +Click "Debug" button + +Step 3 +Inspect page, go to sources, open up base/src and find ts files of interest (greeter.spec.ts and greeter.ts). + +Step 4 +Set breakpoints in browser and refresh page + + +## Helpful Hints + +May wish to install karma and karma-cli globally: + +`npm install karma karma-cli -g` +Then you can run using: +`karma start` \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index 4eb25d2..5e9e8aa 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -6,7 +6,7 @@ module.exports = function(config) { "**/*.ts": "karma-typescript" }, reporters: ["progress", "karma-typescript"], - browsers: ["Chrome"], + browsers: ["ChromeHeadless"], singleRun: true }) } \ No newline at end of file diff --git a/package.json b/package.json index 71e1292..9a85d06 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "scripts": { "build": "rollup -c", "watch": "rollup -cw", + "prod:test": "./node_modules/karma/bin/karma start", "test": "./node_modules/karma/bin/karma start --no-single-run --browser=Chrome" }, "author": "leif stawnyczy", diff --git a/rollup.config.js b/rollup.config.js index c2fa95c..fab2b31 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -10,7 +10,7 @@ export default { { file: 'dist/bundle.js', format: 'iife', - name: 'version' + name: 'MyNamespace' } ], external: [ diff --git a/src/index.ts b/src/index.ts index 72ef95e..8a7d809 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,15 @@ import { Greeter } from "./greeter"; -let greeter = new Greeter(); +export class Test { + greeter: Greeter; -greeter.greet(); \ No newline at end of file + constructor() { + this.greeter = new Greeter(); + + this.greeter.greet(); + } + + callme() { + console.log(this.greeter.returnSomething(1.2)); + } +} diff --git a/test/index.html b/test/index.html index 5c5b2cf..2858e27 100644 --- a/test/index.html +++ b/test/index.html @@ -1,3 +1,4 @@ +