Switch to using new jasmine-browser-runner to server files for local testing

This commit is contained in:
Gregg Van Hove
2019-03-11 17:27:46 -07:00
parent 8da1fd1ed1
commit 0644731680
11 changed files with 53 additions and 93 deletions

View File

@@ -64,7 +64,7 @@ Jasmine supports the following environments:
* Node.js
* 8
* 10
* 11
* 12
## Development
@@ -80,9 +80,9 @@ To install the Node dependencies, you will need Node.js, Npm, and [Grunt](http:/
...will install all of the node modules locally. Now run
$ grunt
$ npm test
...if you see that JSHint runs, your system is ready.
...you should see tests run and eslint checking formatting.
### How to write new Jasmine code
@@ -93,7 +93,7 @@ Or, How to make a successful pull request
* _Be browser agnostic_ - if you must rely on browser-specific functionality, please write it in a way that degrades gracefully
* _Write specs_ - Jasmine's a testing framework; don't add functionality without test-driving it
* _Write code in the style of the rest of the repo_ - Jasmine should look like a cohesive whole
* _Ensure the *entire* test suite is green_ in all the big browsers, Node, and JSHint - your contribution shouldn't break Jasmine for other users
* _Ensure the *entire* test suite is green_ in all the big browsers, Node, and ESLint - your contribution shouldn't break Jasmine for other users
Follow these tips and your pull request, patch, or suggestion is much more likely to be integrated.
@@ -105,35 +105,19 @@ Jasmine uses some internal tooling to test itself in browser on Travis. This too
You can also set the `JASMINE_BROWSER` environment variable to specify which browser should be used.
Jasmine uses the [Jasmine NPM package](http://github.com/jasmine/jasmine-npm) to test itself in a Node.js/npm environment.
$ npm test
...and then the results will print to the console. All specs run except those that expect a browser (the specs in `spec/html` are ignored).
The easiest way to run the tests in **Internet Explorer** is to run a VM that has IE installed. It's easy to do this with VirtualBox.
__Note__: these steps currently still rely on the Jasmine ruby gem and not the new Node.js based tooling. To install the Ruby dependencies, you will need Ruby, Rubygems, and Bundler available. Then:
$ bundle
...will install all of the Ruby dependencies. If the ffi gem fails to build its native extensions, you may need to manually install some system dependencies. On Ubuntu:
$ apt-get install gcc ruby ruby-dev libxml2 libxml2-dev libxslt1-dev
...should get you to the point that `bundle` can install everything.
1. Download and install [VirtualBox](https://www.virtualbox.org/wiki/Downloads).
1. Download a VM image [from Microsoft](https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/). Select "VirtualBox" as the platform.
1. Unzip the downloaded archive. There should be an OVA file inside.
1. In VirtualBox, choose `File > Import Appliance` and select the OVA file. Accept the default settings in the dialog that appears. Now you have a Windows VM!
1. Run the VM and start IE.
1. With `bundle exec rake jasmine` running on your host machine, navigate to `http://10.0.2.2:8888` in IE.
1. With `npm run serve` running on your host machine, navigate to `http://10.0.2.2:8888` in IE.
## Before Committing or Submitting a Pull Request
1. Ensure all specs are green in browser *and* node
1. Ensure JSHint is green with `grunt jshint`
1. Ensure eslint and prettier are clean as part of your `npm test` command. You can run `npm run cleanup` to have prettier re-write the files.
1. Build `jasmine.js` with `grunt buildDistribution` and run all specs again - this ensures that your changes self-test well
1. Revert your changes to `jasmine.js` and `jasmine-html.js`
* We do this because `jasmine.js` and `jasmine-html.js` are auto-generated (as you've seen in the previous steps) and accepting multiple pull requests when this auto-generated file changes causes lots of headaches

View File

@@ -1,6 +1,6 @@
language: node_js
node_js:
- "11"
- "12"
- "10"
- "8"

View File

@@ -1,9 +1,2 @@
source 'https://rubygems.org'
gem "jasmine", :git => 'https://github.com/jasmine/jasmine-gem.git'
# gem "jasmine", path: "../jasmine-gem"
gemspec
gem "jasmine_selenium_runner", :github => 'jasmine/jasmine_selenium_runner'
gem "anchorman"

View File

@@ -1,4 +1,4 @@
Copyright (c) 2008-2017 Pivotal Labs
Copyright (c) 2008-2019 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

View File

@@ -1,18 +0,0 @@
require "bundler"
Bundler::GemHelper.install_tasks
require "json"
require "jasmine"
unless ENV["JASMINE_BROWSER"] == 'phantomjs'
require "jasmine_selenium_runner"
end
load "jasmine/tasks/jasmine.rake"
namespace :jasmine do
task :set_env do
ENV['JASMINE_CONFIG_PATH'] ||= 'spec/support/jasmine.yml'
end
end
task "jasmine:configure" => "jasmine:set_env"
task :default => "jasmine:ci"

View File

@@ -16,8 +16,4 @@ Gem::Specification.new do |s|
s.files = Dir.glob("./lib/**/*")
s.require_paths = ["lib"]
s.add_development_dependency "rake"
s.add_development_dependency "sauce-connect"
s.add_development_dependency "compass"
s.add_development_dependency "jasmine_selenium_runner", ">= 0.2.0"
end

View File

@@ -13,9 +13,10 @@
"bdd"
],
"scripts": {
"pretest": "eslint src/**/*.js spec/**/*.js && prettier --check src/**/*.js spec/**/*.js",
"posttest": "eslint src/**/*.js spec/**/*.js && prettier --check src/**/*.js spec/**/*.js",
"test": "grunt execSpecsInNode",
"cleanup": "prettier --write src/**/*.js spec/**/*.js"
"cleanup": "prettier --write src/**/*.js spec/**/*.js",
"serve": "node spec/support/localJasmineBrowser.js"
},
"description": "Official packaging of Jasmine's core files for use by Node.js projects.",
"homepage": "https://jasmine.github.io",
@@ -32,6 +33,7 @@
"grunt-css-url-embed": "^1.11.1",
"grunt-sass": "^3.0.2",
"jasmine": "^3.4.0",
"jasmine-browser-runner": "0.0.2",
"jsdom": "^15.0.0",
"load-grunt-tasks": "^4.0.0",
"node-sass": "^4.11.0",

View File

@@ -0,0 +1,33 @@
{
"srcDir": "src",
"srcFiles": [
"core/requireCore.js",
"core/base.js",
"core/util.js",
"core/Spec.js",
"core/Env.js",
"core/JsApiReporter.js",
"core/PrettyPrinter.js",
"core/Suite.js",
"core/**/*.js",
"html/**/*.js",
"**/*.js"
],
"specDir": "spec",
"specFiles": [
"**/*[Ss]pec.js",
"!npmPackage/**/*"
],
"helpers": [
"helpers/asyncAwait.js",
"helpers/BrowserFlags.js",
"helpers/checkForMap.js",
"helpers/checkForSet.js",
"helpers/checkForSymbol.js",
"helpers/checkForTypedArrays.js",
"helpers/integrationMatchers.js",
"helpers/promises.js",
"helpers/defineJasmineUnderTest.js"
],
"random": true
}

View File

@@ -1,35 +0,0 @@
#This 'magic' inclusion order allows the travis build to pass.
#TODO: search for the correct files to include to prevent
src_dir:
- 'src'
src_files:
- 'core/requireCore.js'
- 'core/base.js'
- 'core/util.js'
#end of known dependencies
- 'core/Spec.js'
- 'core/Env.js'
- 'core/JsApiReporter.js'
- 'core/PrettyPrinter.js'
- 'core/Suite.js'
- 'core/**/*.js'
- 'html/**/*.js'
- '**/*.js'
stylesheets:
helpers:
- 'helpers/asyncAwait.js'
- 'helpers/BrowserFlags.js'
- 'helpers/checkForMap.js'
- 'helpers/checkForSet.js'
- 'helpers/checkForSymbol.js'
- 'helpers/checkForTypedArrays.js'
- 'helpers/integrationMatchers.js'
- 'helpers/promises.js'
- 'helpers/defineJasmineUnderTest.js'
spec_files:
- '**/*[Ss]pec.js'
- '!npmPackage/**/*'
spec_dir: spec
random: true
spec_helper: spec/support/jasmine_helper.rb

View File

@@ -1,3 +0,0 @@
Jasmine.configure do |config|
config.prevent_phantom_js_auto_install = true
end

View File

@@ -0,0 +1,8 @@
var path = require('path'),
jasmineBrowser = require('jasmine-browser-runner'),
jasmineCore = require('../../lib/jasmine-core.js');
var config = require(path.resolve('spec/support/jasmine-browser.json'));
config.jasmineCore = jasmineCore;
jasmineBrowser.startServer(config);