Skip to content

Commit

Permalink
Merge pull request #8 from Roozenboom/feature/upgrade-nx-16
Browse files Browse the repository at this point in the history
feat: update to nx 16.0.0
  • Loading branch information
Roozenboom committed May 2, 2023
2 parents 9fde9d2 + 052136c commit 2baa961
Show file tree
Hide file tree
Showing 37 changed files with 7,690 additions and 13,033 deletions.
8 changes: 4 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
Expand All @@ -23,12 +23,12 @@
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

### [@rbnx/webdriverio](https://github.com/roozenboom/rbnx/tree/main/packages/webdriverio)

A [Nx plugin](https://nx.dev/packages/nx-plugin) that adds the [WebdriverIO](https://webdriver.io/) testing framework to a NX workspace.
A [Nx plugin](https://nx.dev/packages/plugin) that adds the [WebdriverIO](https://webdriver.io/) testing framework to a NX workspace.
2 changes: 1 addition & 1 deletion e2e/webdriverio-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"sourceRoot": "e2e/webdriverio-e2e/src",
"targets": {
"e2e": {
"executor": "@nrwl/nx-plugin:e2e",
"executor": "@nx/plugin:e2e",
"options": {
"target": "webdriverio:build",
"coverageDirectory": "coverage/e2e/webdriverio-e2e",
Expand Down
45 changes: 32 additions & 13 deletions e2e/webdriverio-e2e/tests/defaults.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { joinPathFragments } from '@nrwl/devkit';
import { joinPathFragments } from '@nx/devkit';
import {
checkFilesExist,
cleanup,
Expand All @@ -7,13 +7,21 @@ import {
runNxCommandAsync,
runCommandAsync,
uniq,
} from '@nrwl/nx-plugin/testing';
} from '@nx/plugin/testing';

describe('webdriverio e2e - defaults', () => {
beforeAll(() => {
const project = uniq('app');
const e2eProject = project + '-e2e';

beforeAll(async () => {
cleanup();
ensureNxProject('@rbnx/webdriverio', 'dist/packages/webdriverio');
});

await runCommandAsync(`npm install --dev @nx/react@latest`);
await runNxCommandAsync(
`generate @nx/react:app ${project} --e2eTestRunner=none --linter=eslint --bundler vite`
);
}, 100000);

afterAll(() => {
runNxCommandAsync('reset');
Expand All @@ -36,16 +44,9 @@ describe('webdriverio e2e - defaults', () => {
).toBeTruthy();

expect(() => checkFilesExist('wdio.base.config.ts')).not.toThrow();
}, 120000);
}, 60000);

it('should create an e2e project and run the e2e executor', async () => {
const project = uniq('app');
const e2eProject = project + '-e2e';

await runCommandAsync(`npm install --dev @nrwl/react@latest`);
await runNxCommandAsync(
`generate @nrwl/react:app ${project} --e2eTestRunner=none --linter=eslint --bundler vite`
);
await runNxCommandAsync(`generate @rbnx/webdriverio:project ${project}`);

const projectJsonPath = joinPathFragments(
Expand All @@ -61,9 +62,27 @@ describe('webdriverio e2e - defaults', () => {
projectJson.targets.e2e.executor === '@rbnx/webdriverio:e2e'
).toBeTruthy();

expect(
projectJson.targets.e2e.options.wdioConfig === 'wdio.config.ts'
).toBeTruthy();

const tsConfigJsonPath = joinPathFragments(
'apps',
e2eProject,
'tsconfig.json'
);
expect(() => checkFilesExist(tsConfigJsonPath)).not.toThrow();
const tsConfigJson = readJson(tsConfigJsonPath);
expect(
tsConfigJson.compilerOptions.types.includes('@wdio/globals/types')
).toBeTruthy();
expect(
tsConfigJson.compilerOptions.types.includes('@wdio/jasmine-framework')
).toBeTruthy();

const result = await runNxCommandAsync(`e2e ${e2eProject} --headless`);
expect(result.stdout).toContain(
`Successfully ran target e2e for project ${e2eProject}`
);
}, 180000);
}, 60000);
});
89 changes: 46 additions & 43 deletions e2e/webdriverio-e2e/tests/devtools.spec.ts
Original file line number Diff line number Diff line change
@@ -1,71 +1,49 @@
import { joinPathFragments } from '@nrwl/devkit';
import { joinPathFragments, names } from '@nx/devkit';
import {
checkFilesExist,
cleanup,
ensureNxProject,
readJson,
runNxCommandAsync,
runCommandAsync,
updateFile,
uniq,
} from '@nrwl/nx-plugin/testing';
readJson,
} from '@nx/plugin/testing';

describe('webdriverio e2e - mocha, devtools and no-auto-config', () => {
beforeAll(() => {
describe('webdriverio e2e - mocha, devtools and localhost', () => {
const project = uniq('app');
const e2eProject = project + '-e2e';
const projectNames = names(project);

beforeAll(async () => {
cleanup();
ensureNxProject('@rbnx/webdriverio', 'dist/packages/webdriverio');
});
await runCommandAsync(`npm install --dev @nx/react@latest`);
await runNxCommandAsync(
`generate @nx/react:app ${project} --e2eTestRunner=none --linter=eslint --bundler vite`
);
}, 100000);

afterAll(async () => {
await runNxCommandAsync('reset');
});

it('should initialize webdriverio nx-plugin', async () => {
it('should create an e2e project with mocha and devtools protocol', async () => {
await runNxCommandAsync(
`generate @rbnx/webdriverio:init --framework=mocha --protocol=devtools`
`generate @rbnx/webdriverio:project ${project} --framework=mocha --protocol=devtools`
);

expect(() => checkFilesExist('package.json')).not.toThrow();

const packageJson = readJson('package.json');

expect(packageJson.devDependencies['@wdio/cli']).toBeTruthy();
expect(packageJson.devDependencies['@wdio/local-runner']).toBeTruthy();
expect(packageJson.devDependencies['@wdio/mocha-framework']).toBeTruthy();
expect(packageJson.devDependencies['@wdio/devtools-service']).toBeTruthy();
expect(packageJson.devDependencies['@wdio/jasmine-framework']).toBeFalsy();
expect(packageJson.devDependencies['@types/jasmine']).toBeFalsy();
expect(packageJson.devDependencies['@wdio/devtools-service']).toBeTruthy();
expect(
packageJson.devDependencies['@wdio/selenium-standalone-service']
).toBeFalsy();

expect(() => checkFilesExist('wdio.base.config.ts')).not.toThrow();
}, 120000);

it('should create an e2e project and run the e2e executor', async () => {
const project = uniq('app');
const e2eProject = project + '-e2e';

await runCommandAsync(`npm install --dev @nrwl/react@latest`);
await runNxCommandAsync(
`generate @nrwl/react:app ${project} --e2eTestRunner=none --linter=eslint --bundler vite`
);
await runNxCommandAsync(
`generate @rbnx/webdriverio:project ${project} --no-auto-config`
);

const projectJsonPath = joinPathFragments(
'apps',
e2eProject,
'project.json'
);
expect(() => checkFilesExist(projectJsonPath)).not.toThrow();
const projectJson = readJson(projectJsonPath);
expect(
projectJson.targets.e2e.executor === '@rbnx/webdriverio:e2e'
).toBeTruthy();
expect(
projectJson.targets.e2e.options.wdioConfig === 'wdio.config.ts'
).toBeTruthy();

const tsConfigJsonPath = joinPathFragments(
'apps',
e2eProject,
Expand All @@ -79,10 +57,35 @@ describe('webdriverio e2e - mocha, devtools and no-auto-config', () => {
expect(
tsConfigJson.compilerOptions.types.includes('@wdio/devtools-service')
).toBeTruthy();
}, 60000);

const result = await runNxCommandAsync(`e2e ${e2eProject}`);
it('should run the e2e executor against localhost', async () => {
const appSpecFilePath = joinPathFragments(
'apps',
e2eProject,
'src',
'e2e',
'app.spec.ts'
);

expect(() => checkFilesExist(appSpecFilePath)).not.toThrow();

updateFile(
appSpecFilePath,
`describe('${projectNames.className}', () => {
it('should have the right title', async () => {
await browser.url('/');
await expect(browser).toHaveTitle('${projectNames.className}');
});
});
`
);

const result = await runNxCommandAsync(
`e2e ${e2eProject} --devServerTarget="${project}:serve:development"`
);
expect(result.stdout).toContain(
`Successfully ran target e2e for project ${e2eProject}`
);
}, 180000);
}, 60000);
});
7 changes: 1 addition & 6 deletions e2e/webdriverio-e2e/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,5 @@
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
"include": ["jest.config.ts", "**/*.spec.ts"]
}
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getJestProjects } from '@nrwl/jest';
import { getJestProjects } from '@nx/jest';

export default {
projects: getJestProjects(),
Expand Down
2 changes: 1 addition & 1 deletion jest.preset.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const nxPreset = require('@nrwl/jest/preset').default;
const nxPreset = require('@nx/jest/preset').default;

module.exports = { ...nxPreset };
2 changes: 1 addition & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"npmScope": "rbnx",
"tasksRunnerOptions": {
"default": {
"runner": "@nrwl/nx-cloud",
"runner": "nx-cloud",
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"],
"accessToken": "MDg4YmI0MGEtOWU5Yy00NjFmLTk5MzctMTYwZjhmMjBjZWQxfHJlYWQtd3JpdGU="
Expand Down
Loading

0 comments on commit 2baa961

Please sign in to comment.