Skip to content

Commit

Permalink
Cleanup of e2e tests
Browse files Browse the repository at this point in the history
Closes bazel-contrib#395

PiperOrigin-RevId: 231848839
  • Loading branch information
gregmagolan authored and Keen Yee Liau committed Jan 31, 2019
1 parent 2e1fd53 commit 8cb6591
Show file tree
Hide file tree
Showing 99 changed files with 675 additions and 3,066 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
node_modules
internal/e2e/ts_auto_deps
internal/e2e/package_karma
internal/e2e/package_karma_stack_trace
internal/e2e/package_typescript_2.7
internal/e2e/package_typescript_2.8
internal/e2e/package_typescript_2.9
internal/e2e/package_typescript_3.0
internal/e2e/package_typescript_3.1
internal/e2e/package_typescript_3.1_no_npm
internal/e2e/package_typescript_karma
devserver/devserver/test/test-workspace
internal/e2e/disable_tsetse_for_external
internal/e2e/npm_packages
internal/e2e/ts_auto_deps
internal/e2e/typescript_3.1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
## IMPORTANT
# If you change the `docker_image` version, also change the `cache_key` suffix
var_1: &docker_image circleci/node:10.12-browsers
var_2: &cache_key rules_typescript-{{ checksum "yarn.lock" }}-internal/karma:{{ checksum "internal/karma/yarn.lock" }}-node:10.12-browsers
var_2: &cache_key rules_typescript-{{ checksum "yarn.lock" }}-node:10.12-browsers
var_3: &setup-bazel-remote-cache
run:
name: Start up bazel remote cache proxy
Expand Down Expand Up @@ -90,9 +90,6 @@ jobs:
key: *cache_key

- run: yarn install
# Build the npm packages which are used in the e2e tests
- run: yarn bazel build //internal:npm_package
- run: yarn bazel build //internal/karma:npm_package
- run: xvfb-run -a yarn e2e

lint:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
.idea
node_modules
/bazel-*
/internal/e2e/package_karma/bazel-*
/internal/e2e/package_typescript_*/bazel-*
/internal/e2e/npm_packages/*/bazel-*
/internal/e2e/npm_packages/*/package.json
/internal/e2e/ts_auto_deps/bazel-*

internal/e2e/ts_auto_deps/simple/BUILD
internal/e2e/ts_auto_deps/simple/BUILD.bazel
/internal/e2e/ts_auto_deps/simple/BUILD
/internal/e2e/ts_auto_deps/simple/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ to
```

The correct defaults to use so that you are not depending on the npm package downstream are in `/internal/defaults.bzl`. Note, your downstream
workspace will also need the correct `@npm` dependencies available to build these targets (see `internal/e2e/package_typescript_3.1_no_npm/package.json`).
workspace will also need the correct `@npm` dependencies available to build these targets (see `internal/e2e/typescript_3.1/package.json`).
In the case of the `angular` workspace, some `@npm` dependencies in this repository will also need to be changed to `@ngdeps` since `angular` does not have
an `@npm` workspace with npm dependencies.

Note, with this workflow the downstream version of `@npm//typescript` will be used to compile the `ts_library` targets in `build_bazel_rules_typescript`.
An example of this can be found under `internal/e2e/package_typescript_3.1_no_npm`.
An example of this can be found under `internal/e2e/typescript_3.1`.

## Releasing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ rules_typescript_dependencies()

rules_typescript_dev_dependencies()

load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies")

rules_nodejs_dependencies()

load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install")

# Use a bazel-managed npm dependency, allowing us to test resolution to these paths
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# End-to-end tests for generated npm packages

All tests that depend on the generated npm packages such as `@bazel/typescript` and `@bazel/karma` should
go in this folder.

## Running

These tests are run using `test.sh` which generates the `package.json` files in each directory before calling `yarn test`.
The `package.json` files are generated from template `package-template.json` files. The absolute locations of
the generated npm packages are substituted in when generating the `package.json` files.

### Running an individual test

To run a specific test run this script with `./internal/e2e/npm_packages/test.sh --test <test_name>` where `<test_name>`
is the name of the test folder to run.

### Updating yarn.lock file

To update the `yarn.lock` files for these tests run `./internal/e2e/npm_packages/test.sh --update-lock-files`.
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "package_karma_e2e")
workspace(name = "npm_packages_karma_e2e")

local_repository(
name = "build_bazel_rules_typescript",
path = "../../..",
path = "../../../..",
)

load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")

rules_typescript_dependencies()

load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies")

rules_nodejs_dependencies()

load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install")

node_repositories(preserve_symlinks = True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ if (typeof module === 'object' && typeof module.exports === 'object') {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
} else if (typeof define === 'function' && define.amd) {
define('package_karma_e2e/decrement', ['require', 'exports'], factory);
define('npm_packages_karma_e2e/decrement', ['require', 'exports'], factory);
}
})(function(require, exports) {
'use strict';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ if (typeof module === 'object' && typeof module.exports === 'object') {
if (v !== undefined) module.exports = v;
} else if (typeof define === 'function' && define.amd) {
define(
'package_karma_e2e/decrement.spec',
['require', 'exports', 'package_karma_e2e/decrement'], factory);
'npm_packages_karma_e2e/decrement.spec',
['require', 'exports', 'npm_packages_karma_e2e/decrement'], factory);
}
})(function(require, exports) {
'use strict';
Object.defineProperty(exports, '__esModule', {value: true});
var decrement_1 = require('package_karma_e2e/decrement');
var decrement_1 = require('npm_packages_karma_e2e/decrement');
describe('decrementing', function() {
it('should do that', function() {
expect(decrement_1.decrement(1)).toBe(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"dependencies": {
"@bazel/karma": "file:${BAZEL_KARMA_NPM_PACKAGE}",
"karma": "3.0.0"
},
"scripts": {
"test": "bazel test ..."
}
}
Loading

0 comments on commit 8cb6591

Please sign in to comment.