Skip to content

Commit

Permalink
feat(examples): illustrate how to run a mocha test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Oct 1, 2019
1 parent d572173 commit ae60c5d
Show file tree
Hide file tree
Showing 14 changed files with 608 additions and 563 deletions.
1 change: 0 additions & 1 deletion examples/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ example_integration_test(
example_integration_test(
name = "examples_webapp",
npm_packages = {
"//packages/jasmine:npm_package": "@bazel/jasmine",
"//packages/protractor:npm_package": "@bazel/protractor",
"//packages/rollup:npm_package": "@bazel/rollup",
"//packages/terser:npm_package": "@bazel/terser",
Expand Down
11 changes: 7 additions & 4 deletions examples/webapp/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@npm//http-server:index.bzl", "http_server")
load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test")
load("@npm//mocha:index.bzl", "mocha_test")
load("@npm_bazel_protractor//:index.bzl", "protractor_web_test_suite")
load(":differential_loading.bzl", "differential_loading")

Expand Down Expand Up @@ -31,10 +31,13 @@ protractor_web_test_suite(
],
)

jasmine_node_test(
mocha_test(
name = "test_sourcemaps",
srcs = ["sourcemaps.spec.js"],
deps = [
# if we were in a subdirectory we'd need
# package_name() + "/*.spec.js"
args = ["*.spec.js"],
data = [
"sourcemaps.spec.js",
":app_chunks",
":app_chunks.min",
":app_chunks_es5",
Expand Down
2 changes: 1 addition & 1 deletion examples/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"@babel/cli": "^7.6.0",
"@babel/core": "^7.6.0",
"@babel/preset-env": "^7.6.0",
"@bazel/jasmine": "latest",
"@bazel/protractor": "latest",
"@bazel/rollup": "latest",
"@bazel/terser": "latest",
"@bazel/typescript": "latest",
"http-server": "^0.11.1",
"mocha": "^6.2.1",
"rollup": "1.21.4",
"source-map": "^0.7.3",
"terser": "^4.3.1",
Expand Down
7 changes: 4 additions & 3 deletions examples/webapp/sourcemaps.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Ensure we have working sourcemaps when the app runs in a browser

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const sm = require('source-map');
Expand Down Expand Up @@ -38,9 +39,9 @@ function asserts(pos) {
// so it actually starts with a bunch of '/../..'
// expect(pos.source).toBe('index.mjs');

expect(pos.source.endsWith('index.mjs')).toBeTruthy();
expect(pos.line).toBe(7); // one-based
expect(pos.column).toBe(20); // zero-based
assert(pos.source.endsWith('index.mjs'));
assert(pos.line == 7); // one-based
assert(pos.column == 20); // zero-based
}

describe('application sourcemaps in the browser', () => {
Expand Down
Loading

0 comments on commit ae60c5d

Please sign in to comment.