Skip to content

Commit

Permalink
refactor(e2e): changes for inclusion in monorepo
Browse files Browse the repository at this point in the history
Co-Authored-By: Sarah Dayan <[email protected]>
  • Loading branch information
Haroenv and sarahdayan committed Nov 24, 2022
1 parent 66c23a0 commit 7c0d464
Show file tree
Hide file tree
Showing 34 changed files with 164 additions and 3,957 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ jobs:
- *restore_yarn_cache
- *run_yarn_install
- run:
name: End-2-End tests
name: End-to-end tests
command: yarn run test:e2e:saucelabs
- store_test_results:
path: junit/wdio/
Expand Down
44 changes: 44 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,50 @@ module.exports = {
],
},
},
{
files: ['tests/e2e/**/*'],
parserOptions: {
project: 'tests/e2e/tsconfig.json',
},
rules: {
'valid-jsdoc': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: 'WebdriverIOAsync',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/no-floating-promises': 'error',
},
},
{
files: [
'tests/e2e/specs/**/*.spec.ts',
'tests/e2e/all-flavors.spec.ts',
'tests/e2e/helpers/**/*.ts',
'tests/e2e/wdio.*.conf.js',
],
extends: ['plugin:wdio/recommended'],
plugins: ['wdio'],
env: {
jasmine: true,
},
rules: {
// we are exporting test "factories", so we need to allow export
'jest/no-export': 0,
// we use jasmine
'jest/expect-expect': 0,
'@typescript-eslint/no-namespace': 0,
},
},
{
files: ['tests/e2e/**/*.js'],
rules: {
'import/no-commonjs': 0,
},
},
],
settings: {
react: {
Expand Down
18 changes: 18 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,24 @@ To run the test continuously based on what you changed (useful when developing o
yarn test --watch
```

### End-to-end tests

End-to-end tests are defined by the [tests/e2e](./tests/e2e/README.md) project.

To run them locally:

```sh
yarn test:e2e:local
```

To run them on saucelabs, with credentials as `SAUCE_USERNAME` and `SAUCE_ACCESS_KEY` environment variable:

```sh
yarn test:e2e:saucelabs
```

More info, including how to write the tests, can be found in its [CONTRIBUTING](./tests/e2e/CONTRIBUTING.md) and [README](./tests/e2e/README.md) files.

### Type checks

Type checks ensure code is correctly typed both for code quality and TypeScript compatibility.
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const config = {
testPathIgnorePatterns: [
'<rootDir>/packages/*/node_modules/',
'<rootDir>/packages/*/dist*',
'<rootDir>/tests/e2e/*',
],
watchPathIgnorePatterns: [
'<rootDir>/packages/*/cjs',
Expand Down
12 changes: 2 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"website:examples": "lerna run website:examples",
"lint": "eslint --ext .js,.ts,.tsx .",
"lint:fix": "eslint --ext .js,.ts,.tsx --fix .",
"type-check": "tsc",
"type-check": "tsc && lerna run type-check",
"type-check:v3": "tsc --project tsconfig.v3.json",
"test": "jest",
"test:size": "bundlesize",
Expand Down Expand Up @@ -46,14 +46,6 @@
"@types/storybook__addon-actions": "3.4.2",
"@typescript-eslint/eslint-plugin": "5.38.1",
"@typescript-eslint/parser": "4.15.1",
"@wdio/cli": "5.16.9",
"@wdio/jasmine-framework": "5.16.5",
"@wdio/junit-reporter": "5.16.11",
"@wdio/local-runner": "5.16.9",
"@wdio/sauce-service": "5.16.5",
"@wdio/selenium-standalone-service": "5.16.5",
"@wdio/spec-reporter": "5.16.5",
"@wdio/static-server-service": "5.16.5",
"algoliasearch": "4.11.0",
"algoliasearch-v3": "npm:[email protected]",
"babel-eslint": "10.0.3",
Expand All @@ -76,7 +68,7 @@
"eslint-plugin-prettier": "3.4.0",
"eslint-plugin-react": "7.18.0",
"eslint-plugin-react-hooks": "2.3.0",
"instantsearch-e2e-tests": "algolia/instantsearch-e2e-tests#feat/monorepo",
"eslint-plugin-wdio": "5.11.0",
"jest": "27.1.0",
"jest-diff": "27.1.0",
"jest-environment-jsdom": "27.1.0",
Expand Down
2 changes: 0 additions & 2 deletions packages/instantsearch.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
"build:types": "scripts/typescript/extract.js",
"storybook": "start-storybook --quiet --port 6006 --ci --static-dir .storybook/static",
"storybook:build": "build-storybook --quiet --output-dir ../../website/stories/js --static-dir .storybook/static",
"type-check": "tsc",
"type-check:v3": "tsc --project tsconfig.v3.json",
"test": "jest",
"test:exports": "node test/module/is-es-module.mjs",
"version": "./scripts/version/update-version.js"
Expand Down
7 changes: 4 additions & 3 deletions scripts/wdio/local.conf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable import/no-commonjs */

const { local } = require('instantsearch-e2e-tests');

exports.config = local;
exports.config = {
...require('@instantsearch/e2e-tests').local,
// you can override the default options if needed here
};
6 changes: 3 additions & 3 deletions scripts/wdio/saucelabs.conf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable import/no-commonjs */

const { saucelabs } = require('instantsearch-e2e-tests');

exports.config = saucelabs;
exports.config = {
...require('@instantsearch/e2e-tests').saucelabs,
};
46 changes: 0 additions & 46 deletions tests/e2e/.circleci/config.yml

This file was deleted.

8 changes: 0 additions & 8 deletions tests/e2e/.editorconfig

This file was deleted.

2 changes: 0 additions & 2 deletions tests/e2e/.eslintignore

This file was deleted.

47 changes: 0 additions & 47 deletions tests/e2e/.eslintrc.js

This file was deleted.

5 changes: 0 additions & 5 deletions tests/e2e/.prettierrc

This file was deleted.

1 change: 0 additions & 1 deletion tests/e2e/.yarnrc

This file was deleted.

7 changes: 7 additions & 0 deletions tests/e2e/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [3.0.0](https://github.com/algolia/instantsearch-e2e-tests/compare/v2.0.1...v2.0.2) (2022-11-23)


### Features

* **tests:** migrate to the InstantSearch monorepo ([#38](https://github.com/algolia/instantsearch-e2e-tests/issues/38))

## [2.0.2](https://github.com/algolia/instantsearch-e2e-tests/compare/v2.0.1...v2.0.2) (2022-02-03)


Expand Down
61 changes: 3 additions & 58 deletions tests/e2e/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,12 @@
# Contributing

This repository contains the end-to-end (e2e) test suite for [InstantSearch](https://github.com/algolia/instantsearch.js). This test suite is meant to be shared across all InstantSearch flavors, this is why it is stored in a separate repository.
This repository contains the end-to-end (e2e) test suite for InstantSearch. This test suite is meant to be shared across all InstantSearch flavors, this is why it is stored in the monorepo.

## Development

### Requirements

To run this project, you will need:

- Node.js >= v8.10.0, use nvm - [install instructions](https://github.com/creationix/nvm#install-script)
- Yarn >= v1.16.0 - [install instructions](https://yarnpkg.com/en/docs/install#alternatives-stable)

### Installation

The easiest way to work on the tests is to link them into an InstantSearch project using [`yarn link`](https://yarnpkg.com/en/docs/cli/link).

First, clone the `instantsearch-e2e-tests` repository, install its dependencies and link it.

```sh
git clone [email protected]:algolia/instantsearch-e2e-tests.git
cd instantsearch-e2e-tests
yarn
yarn link
```

Then, clone the [`instantsearch.js`](https://github.com/algolia/instantsearch.js/) repository (or any other flavor), install its dependencies and link `instantsearch-e2e-tests`.

```sh
git clone [email protected]:algolia/instantsearch.js
cd instantsearch.js
yarn
yarn link instantsearch-e2e-tests
```

You can now run your local end-2-end test suite using the `test:e2e:*` scripts from the InstantSearch project.
Running the tests

```sh
yarn test:e2e # Run the test suite on Chrome browser on your local machine
Expand All @@ -60,7 +33,7 @@ One spec file represents a scenario to test a behavior from a user point of view

Example of scenario:

1. Load the `examples/e-commerce/` page
1. Load the `examples/js/e-commerce/` page
2. Click on "Appliances" category
3. Click on rating "4 & up"
4. Check if the result list matches the expected one
Expand Down Expand Up @@ -122,31 +95,3 @@ A library of helpers is available in the [`helpers`](helpers) directory and are
These helpers are here to simplify the writing of tests, their readability and their maintenance. You are strongly encouraged to use them in your tests and to contribute to the helpers library.

You can find more information about helpers in [WebdriverIO documentation](https://webdriver.io/docs/customcommands.html#adding-custom-commands).

## Release

This project uses [AngularJS's commit message convention](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines) with [Commitizen](http://commitizen.github.io/cz-cli/).

### Commit current changes

```sh
yarn commit
```

### Release a new version

```sh
yarn version
```

### Updating dependents projects

This package is not published on the npm registry. To update the test suite in an InstantSearch project, run the following command in it:

```sh
yarn add -D "algolia/instantsearch-e2e-tests#XXX"
```

(`XXX` being the tag for the version you want to install)

If [Renovate](https://renovatebot.com/) is enabled on your project then it should update it automatically like any other dependency.
21 changes: 0 additions & 21 deletions tests/e2e/LICENSE

This file was deleted.

Loading

0 comments on commit 7c0d464

Please sign in to comment.