@mands/nx-playwright
Advanced tools
Comparing version 0.1.27 to 0.1.28
{ | ||
"name": "@mands/nx-playwright", | ||
"version": "0.1.27", | ||
"version": "0.1.28", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
@@ -17,2 +17,6 @@ "use strict"; | ||
const playwrightInitTask = yield (0, generator_1.default)(host, { skipFormat: true }); | ||
const workspaceProjects = (0, devkit_1.getProjects)(host); | ||
if (options.project && !workspaceProjects.has(options.project)) { | ||
return Promise.reject(`${options.project} is not a valid project in the workspace`); | ||
} | ||
(0, devkit_1.addProjectConfiguration)(host, normalizedOptions.projectName, { | ||
@@ -19,0 +23,0 @@ root: normalizedOptions.projectRoot, |
@@ -1,4 +0,4 @@ | ||
import type { Tree } from '@nrwl/devkit'; | ||
import { addProjectConfiguration, readJson, updateWorkspaceConfiguration } from '@nrwl/devkit'; | ||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; | ||
import { Linter } from '@nrwl/linter'; | ||
import { FsTree } from 'nx/src/generators/tree'; | ||
import generator from './generator'; | ||
@@ -8,4 +8,5 @@ | ||
it('generates correct project.json with required options + project', async () => { | ||
const host: Tree = new FsTree('.', true); | ||
const generate = await generator(host, { | ||
const host = createTree(); | ||
await generator(host, { | ||
name: 'test-generator', | ||
@@ -15,5 +16,3 @@ linter: Linter.EsLint, | ||
}); | ||
await generate(); | ||
const projectJsonString = host.read('e2e/test-generator/project.json').toString(); | ||
const projectJson = JSON.parse(projectJsonString); | ||
const projectJson = readJson(host, 'e2e/test-generator/project.json'); | ||
@@ -60,5 +59,16 @@ expect(projectJson).toEqual({ | ||
it('returns correct error message when provided project does not exist', async () => { | ||
const host = createTree(); | ||
await expect( | ||
generator(host, { | ||
name: 'test-generator', | ||
linter: Linter.EsLint, | ||
project: 'bad-project', | ||
}), | ||
).rejects.toMatchInlineSnapshot(`"bad-project is not a valid project in the workspace"`); | ||
}); | ||
it('generates correct project.json with required options + project, packageRunner', async () => { | ||
const host: Tree = new FsTree('.', true); | ||
const generate = await generator(host, { | ||
const host = createTree(); | ||
await generator(host, { | ||
name: 'test-generator', | ||
@@ -69,5 +79,3 @@ linter: Linter.EsLint, | ||
}); | ||
await generate(); | ||
const projectJsonString = host.read('e2e/test-generator/project.json').toString(); | ||
const projectJson = JSON.parse(projectJsonString); | ||
const projectJson = readJson(host, 'e2e/test-generator/project.json'); | ||
@@ -114,1 +122,14 @@ expect(projectJson).toEqual({ | ||
}); | ||
function createTree() { | ||
const host = createTreeWithEmptyWorkspace(); | ||
updateWorkspaceConfiguration(host, { | ||
workspaceLayout: { | ||
appsDir: 'e2e', | ||
libsDir: 'packages', | ||
}, | ||
version: 2, | ||
}); | ||
addProjectConfiguration(host, 'test-project', { root: './apps/test-project' }); | ||
return host; | ||
} |
Sorry, the diff of this file is not supported yet
48759
900