The basic idea is to build a production application ensuring consistent and stable code using JavaScript, CSS and bootstrap linting and automated unit and e2e testing. This will be in part, assisted by the development tools, detailed in the Development Overview and bundle sections. Parcel, Rollup and Webpack now use Vue 3. The Vue 2 bundlers are located in public/vue2
. Vite was added for vue3 and is located in public/vite
.
Dodex: Added for testing and demo. https://github.com/DaveO-Home/dodex
- Canjs - https://github.com/DaveO-Home/embedded-acceptance-tests
- Angular - https://github.com/DaveO-Home/embedded-acceptance-tests-ng
- React - https://github.com/DaveO-Home/embedded-acceptance-tests-react
Dockerfile: See instructions at bottom of README.
- Gulp
- Karma
- Jasmine
- Any Browser with a karma launcher
- Javascript bundling tools
- See
public/package.json
for details - Node, npm - node v10 or greater works best
- Vite/Cypress
Desktop:
Clone the repository or download the .zip
Install Assumptions:
- OS Linux or Windows(Tested on Windows10)
- Node and npm
- Gulp4 is default - If your global Gulp is version 3, you can execute
npx gulp
from the build directories. - Google Chrome
- Firefox
Server:
cd
to top level directory <install>/acceptance-tests-vue
npm install or npm install --legacy-peer-deps( or --force)
This will install a small Node/Koa setup to view the results of a production/test builds.
cd <install>/acceptance-tests-vue/public
npm install or npm install --legacy-peer-deps( or --force)
To view the vulnerabilities that are actually bundled, execute npm audit --omit dev
.
To install required dependencies. Currently this will install Vue3 for Parcel, Rollup and Webpack.
cd <install>/acceptance-tests-vue/public/vue2
To install required dependencies for Browserify, Brunch, FuseBox and Stealjs for Vue2. If trying Brunch, install the global package for Brunch, npm install brunch -g
.
Note: To fix some of the javascript vulnerabilities, execute npm audit fix
. To view the vulnerabilities that are actually bundled, execute npm audit --omit dev
.
Client:
Test builds will generate bundles in dist_test
and production in the dist
directory at the root level, public
for Vue3 bundlers. The distribution directories for Vue2 are under the public/vue2
directory. The dodex message client works out of the box, however with vue it may take a few seconds before the connect is made. Just ctrl-double click
a dodex dial or the static page to initiate the dodex message client.
To generate a build "cd to public/<bundler>/build
and type gulp
, e.g.
cd public/parcel/build
gulp test or npx gulp test
In lieu of changing to the .../build directories, you can use the bm
script by simply executing bm parcel test
etc, from the ".../public" directory or ".../public/vue2" directory.
If the tests succeed then the build should complete.
To run the production application:
cd <install>/acceptance_tests-vue
npm start
- This should start a Node Server with port 3080.- Start a browser and enter
localhost:3080/dist/<bundler>/appl/testapp.html
- For the vue2 versions, the Production Url is
localhost:3080/vue2/dist/<bundler>/testapp.html
You can repeat the procedure with "webpack", "browserify", "stealjs", "brunch", "parcel" or "rollup". Output from the build can be logged by setting the environment variable USE_LOGFILE=true
.
Normally you can also run the test bundles(dist_test) from the node koa server. However, when switching between development karma testing and running the test(dist_test) application, some resources are not found because of the "base/dist_test" URL. To fix this run gulp rebuild
from the <bundler>/build
directory.
The test build simply runs the tests in headless mode. The default browsers are ChromeHeadless and FirefoxHeadless. To change the default you can set an environment variable; e.g.
export USE_BROWSERS=ChromeHeadless,Opera
to remove FirefoxHeadless from the browser list and add Opera. You can also set this environment variable for a production build.
The easiest way to run the tests is to execute the convenience script bm
, "bm webpack test" for example.
Otherwise, to run the tests "cd to public/<bundler>/build
or public/vue2/<bundler>/build
and type gulp test
or npx gulp test
, e.g.
cd public/webpack/build
npx gulp test
A test result might look like;
Suite for Unit Tests
✔ Verify that browser supports Promises
✔ ES6 Support
✔ blockStrip to remove Canjs block of code
Unit Tests - Suite 2
✔ Is Karma active
✔ Verify NaN
Popper Defined - required for Bootstrap
✔ is JQuery defined
✔ is Popper defined
Application Unit test suite - AppTest
✔ Is Welcome Page Loaded
✔ Is Tools Table Loaded
Test Router: table/tools
✔ controller set: table
✔ action set: tools
✔ dispatch called: table
✔ Is Pdf Loaded
Test Router: pdf/test
✔ controller set: pdf
✔ action set: test
✔ dispatch called: pdf
Load new tools page
✔ setup and change event executed.
✔ new page loaded on change.
Contact Form Validation
✔ Contact form - verify required fields
✔ Contact form - validate populated fields, email mismatch.
✔ Contact form - validate email with valid email address.
✔ Contact form - validate form submission.
Popup Login Form
✔ Login form - verify modal with login loaded
✔ Login form - verify cancel and removed from DOM
Dodex Operation Validation
✔ Dodex - loaded and toggle on icon mousedown
✔ Dodex - Check that card A is current and flipped on mousedown
✔ Dodex - Check that card B is current and flipped on mousedown
✔ Dodex - Flip cards A & B back to original positions
✔ Dodex - Flip multiple cards on tab mousedown
✔ Dodex - Add additional app/personal cards
✔ Dodex - Load Login Popup from card1(A)
Dodex Input Operation Validation
✔ Dodex Input - popup on mouse double click
✔ Dodex Input - Verify that form elements exist
✔ Dodex Input - verify that uploaded file is processed
✔ Dodex Input - close popup on button click
Finished in 13.883 secs / 9.677 secs @ 13:26:11 GMT-0800 (PST)
SUMMARY:
✔ 72 tests completed
Note: When modifying project assets(.handlebars, .html, etc.) you can execute gulp copy
from the public/<bundler>/build
or public/vue2/<bundler>/build
directory to preview changes. This is not required for StealJs.
A word on developing tests; You can write and execute tests quicker by using the rebuild process of a given bundler and running the acceptance
gulp task after the auto-rebuild, e.g. with Rollup you can;
-
cd public/rollup/build
-
gulp watch
-
Develop or modify a test.
-
In another window execute
gulp acceptance
from thebuild
directory to view the modified or new test results.Also Note: With a few of the bundle tools, execute the
gulp development
task to run from one window.
-
Development Server Window -
cd public/vue2/browserify/build
gulp server
Browsersync will start a browser tab(default Chrome) with
localhost:3080/vue2/dist_test/browserify/appl/testapp_dev.html
. Any changes to the source code(*.js files) should be reflected in the browser auto reload. -
Hot Module Reload(HMR) Window -
cd public/vue2/browserify/build
gulp hmr
The
watchify
plugin will remain active to rebuild the bundle on code change. -
Test Driven Development(tdd) Window -
cd public/vue2/browserify/build
gulp tdd
Tests will rerun as source code(*.js) is changed. Note, tests can be added or removed as code is developed. Both Chrome and Firefox are the default browsers. This can be overridden with an environment variable,
export USE_BROWSERS=Opera
. Note, you do not needhmr
active fortdd
. Also,tdd
can be run with a headless browser.
-
Watch, Recompile and Reload Window -
cd public/vue2/brunch/build
gulp watch
or./cook watch
(output formatted better)
At this point you can start a browser and enter
localhost:3080/appl/testapp_dev.html
. Any changes to the source code(.js files and other assets such as.html) should be reflected in the browser auto reload.Note: The test url is
localhost:3080
since Brunch by default uses 'config.paths.public' as the server context. Also, the reload may fail at times, after making a second code modification reload should succeed. -
Test Driven Development(tdd) Window -
cd public/vue2/brunch/build
gulp tdd
or./cook tdd
While the Brunch watcher is running, tests are re-run when code are changed.
Note: tests can be added or removed as code is developed. Both Chrome and Firefox are the default browsers. This can be overridden with an environment variable,
export USE_BROWSERS=Opera
. -
Special Considerations
- Brunch plugin eslint-brunch uses eslint 3. The demo/vue uses version 4. The
gulp
(production build) command uses a gulp linter, so javascript linting is executed. However, if you wish to use the Brunch eslint-brunch plugin, do the following;cd <install>/public/vue2/node_modules/eslint-brunch
npm install eslint@latest
cd <install>/public/vue2
and edit thebrunch-config.js
file and uncomment the eslint section.
- Brunch plugin eslint-brunch uses eslint 3. The demo/vue uses version 4. The
-
Hot Module Reload(HMR) Server Window -
cd public/esbuild/build
gulp hmr
- HMR will start a web server with port 3080, a watcher will also start that rebuilds the bundle on code change.
HMR is using
browser-sync
so a web page will start at:localhost:3080/dist_test/esbuild/appl/testapp_dev.html
. Any changes to the source code(*.js|*.jsx) files should be reflected in the browser auto reload. Also, the browser will reload when changing static content by executinggulp copy
.For development and testing, the normal tasks;
gulp test
,gulp acceptance
,gulp rebuild
can be executed when needed. -
Test Driven Development(tdd) Window -
cd public/esbuild/build
gulp tdd
You must use
gulp build
and not gulp rebuild withgulp tdd
running. Tdd will fail with gulp rebuild because it cleans the test directory.The HMR Server must be running if you want tests to rerun as source code(*.js) are changed.
Note: tests can be added or removed as code is developed. Both Chrome and Firefox are the default browsers. This can be overridden with an environment variable,export USE_BROWSERS=Opera
.
-
Hot Module Reload(HMR) Server Window -
cd public/vue2/fusebox/build
gulp hmr
orfuse hmr
At this point you can start a browser and enter
localhost:3080/vue2/fusebox/appl/testapp_dev.html
. Any changes to the source code(*.js files) should be reflected in the browser auto reload. -
Test Driven Development(tdd) Window -
-
cd public/vue2/fusebox/build
-
gulp tdd
The HMR Server must be running if you want tests to rerun as source code(*.js) is changed.
Note: tests can be added or removed as code is developed. Both Chrome and Firefox are the default browsers. This can be overridden with an environment variable,
export USE_BROWSERS=Opera
. A warning is issued undertdd
(404: /dist_test/fusebox/resources) sincehmr
requires a non-karma build, this can be ignored.
-
-
Watch, Recompile and Reload Window -
cd public/parcel/build
gulp watch
orgulp serve
At this point you can start a browser and enter
localhost:3080/dist_test/parcel/appl/testapp_dev.html
(can be configured to auto open browser tab). Any changes to the source code(.js and.css files) should be reflected in the browser auto reload.
Note: Withparcel V2
, the parcel internal server is used. To allow the same test URL, a proxy has been added using.../public/.proxyrc
. The HMR reload seems to have a problem, you may need to reload the browser manually. -
Test Driven Development(tdd) Window -
cd public/parcel/build
gulp tdd
While the Parcel watcher is running, tests are re-run when code are changed.
- Using
export USE_BUNDLER=false
- When usinggulp watch & gulp tdd
together, you can set USE_BUNDLER to false to startup TDD without building first,gulp watch
does the test build. Also, by setttingUSE_BUNDLER=false
beforegulp
(production build), only testing and linting will execute.
Note: tests can be added or removed as code is developed. Both Chrome and Firefox are the default browsers. This can be overridden with an environment variable,
export USE_BROWSERS=Opera
.
-
Development Server Window -
cd public/rollup/build
gulp watch
The Rollup Development Server, Watch(auto-rebuild) and Page Reload functions are started together. Simply use the following URL in any browser;
localhost:3080/dist_test/rollup/appl/testapp_dev.html
. -
Test Driven Development(tdd) Window -
cd public/rollup/build
gulp tdd
Tests will rerun as source code(*.js) is changed. Note, tests can be added or removed as code is developed. Both Chrome and Firefox are the default browsers. This can be overridden with an environment variable,
export USE_BROWSERS=Opera
.
-
Development Server Window -
cd public/vue2/stealjs/build
gulp server
-
Live-Reload(HMR) Window -
cd public/stealjs/build
gulp hmr
At this point you can start a browser and enter
localhost:3080/vue2/stealjs/appl/testapp_dev.html
(please note that dist_test is not in the URL). Any changes to the source code(*.js files) should be reflected in the browser auto reload. Thegulp hmr
by default builds a vendor bundle for faster reload. When you are not modifying the node_modules directory, subsequent executions ofgulp hmr
do not need the vendor bundle build. You can disable by setting an environment variable,export USE_VENDOR_BUILD=false
.Stealjs does not require a dist_test build. It runs development directly from the source(nice!). However, when starting
hmr
a vendor bundle is produced at public/dev-bundle.js forhmr
performance. The bundle is accessed from thetestapp_dev.html
page, via adeps-bundle
attribute. -
Test Driven Development(tdd) Window -
cd public/vue2/steal/build
gulp tdd
Tests will rerun as source code(*.js) is changed. Note, tests can be added or removed as code is developed. Both Chrome and Firefox are the default browsers. This can be overridden with an environment variable,
export USE_BROWSERS=Opera
.
-
Development HMR Server Window -
cd public/webpack/build
gulp hmr
This will start a server and watcher. View the application in a browser using URL
localhost:3080/dist_test/webpack/appl/testapp_dev.html
. Any code changes should be reflected in the auto reload. -
Hot Module Reload(Watch) Window -
cd public/webpack/build
gulp watch
This rebuilds the application. If a server in running, e.g.
npm start
in<install>/acceptance_tests-vue
, a manual refresh will reflect the change when executinglocalhost:3080/dist_test/webpack/appl/testapp_dev.html
. -
Test Driven Development(tdd) Window -
cd public/webpack/build
gulp tdd
Tests will rerun as source code(*.js) is changed. Note, tests can be added or removed as code is developed. Both Chrome and Firefox are the default browsers. This can be overridden with an environment variable,
export USE_BROWSERS=Opera
.
- Vite is loacated in the
public/vite
directory. - The vite setup does not use
gulp
rather it usesnpm
scripts, seevite/package.json
. - To install, execute
npm install
ornpm install --legacy-peer-deps (--force)
in both<install dir>/public
and<install dir>/public/vite
.
Production -
- Execute
npm run prod
to run full testing, linting and build. (Cypress
andKarma
testing) - Execute
npm run build
to build without the tests. The build is located invite/dist
. - Execute
npm start
from the main install directory to run theKoa
server and use Urllocalhost:3080/vite/dist/index.html
. - You can also use
npm run serve
from theVite
directory to start a server at port 5000. However you will need to use theNetwork host
displayed in the terminal. Running production from the dev server,npm run dev
with Urllocalhost:4080/dist/index.html
may work. - Execute
npm copy
to recopy static files to thedist
directory. - Execute
npm run integration
to runkarma
embedded tests.
Note: Thekarma
tests run against the production build. - Execute
npm run integrationp
to run thekarma
test against an existing production bundle.
Developemnt -
- Exeucte
npm run dev
to start the development server. Code changes will be reflected in the browser atlocalhost:4080
.
Note:npm run dev
executesvite
and dynamically setups up the application via modules, no bundles are created. Good for large applications. - Execute
npm run tdd
to start up both thedev
server andcypress
to run test driven development. This will also reload the browser atlocalhost:4080
. - Execute
npm run acceptance
to run all of the definedcypress
tests in the e2e directory. - Execute
npm run lint
to lint the application(js and vue) files. - Execute
npm run component
to run cypress component tests.
You can build a complete test/develpment environment on a Docker vm with the supplied Dockerfile.
Linux as Parent Host(assumes docker is installed and daemon is running)-
In the top parent directory, usually ..../embedded-acceptance-tests-vue/
execute the following commands;
-
docker build -t embedded fedora
ordocker build -t embedded centos
-
docker run -ti --privileged -p 3080:3080 -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --name test_env embedded bash
You should be logged into the test container(test_env). There will be 4 embedded-acceptance-tests* directories. Change into to default directory defined in the Dockerfile, for example canjs(embedded-acceptance-tests/public). All of the node dependencies should be installed, so
cd
to a desired bundler build directory, i.e.stealjs/build
and follow the above instructions on testing, development and production builds. -
When existing the vm after the
docker run
command, the container may be stopped. To restart executedocker start test_env
and thendocker exec -it --privileged --user tester -e DISPLAY=$DISPLAY -w /home/tester test_env bash
. You can also use--user root
to execute admin work.
Windows as Parent Host-
For Pro and Enterpise OS's, follow the Docker instructions on installation. For the Home OS version you can use the legacy Docker Desktop client. It is best to have a Pro or Enterpise Windows OS to use a WSL(Windows bash) install. Use following commands with Windows;
-
docker build -t embedded fedora
ordocker build -t embedded centos
-
docker run -ti --privileged -p 3080:3080 --name test_env embedded bash
-
docker exec -it --privileged --user tester -w /home/tester test_env bash
The web port 3080 is exposed to the parent host, so once an application is sucessfully bundled and the node server(npm start
in directory embedded-acceptance-tests) is started, a host browser can view the application using say localhost:3080/dist/webpack/appl/testapp.html
.
Note: Without a complete Pro/Enterprise docker installation, the test_env
container can only run with Headless browsers. Therfore you should execute export USE_BROWSERS=ChromeHeadless,FirefoxHeadless
before testing, development and building.