Primeiro commit do projeto Angular
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
// @ts-check
|
||||
// Protractor configuration file, see link for more information
|
||||
// https://github.com/angular/protractor/blob/master/lib/config.ts
|
||||
|
||||
const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter');
|
||||
|
||||
/**
|
||||
* @type { import("protractor").Config }
|
||||
*/
|
||||
exports.config = {
|
||||
allScriptsTimeout: 11000,
|
||||
specs: [
|
||||
'./src/**/*.e2e-spec.ts'
|
||||
],
|
||||
capabilities: {
|
||||
browserName: 'chrome'
|
||||
},
|
||||
directConnect: true,
|
||||
SELENIUM_PROMISE_MANAGER: false,
|
||||
baseUrl: 'http://localhost:4200/',
|
||||
framework: 'jasmine',
|
||||
jasmineNodeOpts: {
|
||||
showColors: true,
|
||||
defaultTimeoutInterval: 30000,
|
||||
print: function() {}
|
||||
},
|
||||
onPrepare() {
|
||||
require('ts-node').register({
|
||||
project: require('path').join(__dirname, './tsconfig.json')
|
||||
});
|
||||
jasmine.getEnv().addReporter(new SpecReporter({
|
||||
spec: {
|
||||
displayStacktrace: StacktraceOption.PRETTY
|
||||
}
|
||||
}));
|
||||
}
|
||||
};
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import { browser, logging } from 'protractor';
|
||||
import { AppPage } from './app.po';
|
||||
|
||||
describe('workspace-project App', () => {
|
||||
let page: AppPage;
|
||||
|
||||
beforeEach(() => {
|
||||
page = new AppPage();
|
||||
});
|
||||
|
||||
it('should display welcome message', async () => {
|
||||
await page.navigateTo();
|
||||
expect(await page.getTitleText()).toEqual('Hello, <%= relatedAppName %>');
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
// Assert that there are no errors emitted from the browser
|
||||
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
|
||||
expect(logs).not.toContain(jasmine.objectContaining({
|
||||
level: logging.Level.SEVERE,
|
||||
} as logging.Entry));
|
||||
});
|
||||
});
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { browser, by, element } from 'protractor';
|
||||
|
||||
export class AppPage {
|
||||
async navigateTo(): Promise<unknown> {
|
||||
return browser.get(browser.baseUrl);
|
||||
}
|
||||
|
||||
async getTitleText(): Promise<string> {
|
||||
return element(by.css('h1')).getText();
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
||||
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
||||
{
|
||||
"extends": "<%= relativePathToWorkspaceRoot %>/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "<%= relativePathToWorkspaceRoot %>/out-tsc/e2e",
|
||||
"module": "commonjs",
|
||||
"target": "es2019",
|
||||
"types": [
|
||||
"jasmine",
|
||||
"node"
|
||||
]
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
import { Rule } from '@angular-devkit/schematics';
|
||||
import { Schema as E2eOptions } from './schema';
|
||||
export default function (options: E2eOptions): Rule;
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const schematics_1 = require("@angular-devkit/schematics");
|
||||
const node_path_1 = require("node:path");
|
||||
const dependency_1 = require("../utility/dependency");
|
||||
const json_file_1 = require("../utility/json-file");
|
||||
const latest_versions_1 = require("../utility/latest-versions");
|
||||
const standalone_1 = require("../utility/standalone");
|
||||
const workspace_1 = require("../utility/workspace");
|
||||
const workspace_models_1 = require("../utility/workspace-models");
|
||||
/**
|
||||
* The list of development dependencies used by the E2E protractor-based builder.
|
||||
* The versions are sourced from the latest versions `../utility/latest-versions/package.json`
|
||||
* file which is automatically updated via renovate.
|
||||
*/
|
||||
const E2E_DEV_DEPENDENCIES = Object.freeze([
|
||||
'protractor',
|
||||
'jasmine-spec-reporter',
|
||||
'ts-node',
|
||||
'@types/node',
|
||||
]);
|
||||
function addScriptsToPackageJson() {
|
||||
return (host) => {
|
||||
const pkgJson = new json_file_1.JSONFile(host, 'package.json');
|
||||
const e2eScriptPath = ['scripts', 'e2e'];
|
||||
if (!pkgJson.get(e2eScriptPath)) {
|
||||
pkgJson.modify(e2eScriptPath, 'ng e2e', false);
|
||||
}
|
||||
};
|
||||
}
|
||||
function default_1(options) {
|
||||
const { relatedAppName } = options;
|
||||
return (0, workspace_1.updateWorkspace)((workspace) => {
|
||||
const project = workspace.projects.get(relatedAppName);
|
||||
if (!project) {
|
||||
throw new schematics_1.SchematicsException(`Project name "${relatedAppName}" doesn't not exist.`);
|
||||
}
|
||||
const e2eRootPath = node_path_1.posix.join(project.root, 'e2e');
|
||||
project.targets.add({
|
||||
name: 'e2e',
|
||||
builder: workspace_models_1.Builders.Protractor,
|
||||
defaultConfiguration: 'development',
|
||||
options: {
|
||||
protractorConfig: node_path_1.posix.join(e2eRootPath, 'protractor.conf.js'),
|
||||
},
|
||||
configurations: {
|
||||
production: {
|
||||
devServerTarget: `${relatedAppName}:serve:production`,
|
||||
},
|
||||
development: {
|
||||
devServerTarget: `${relatedAppName}:serve:development`,
|
||||
},
|
||||
},
|
||||
});
|
||||
return (0, schematics_1.chain)([
|
||||
(0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
||||
(0, schematics_1.applyTemplates)({
|
||||
utils: schematics_1.strings,
|
||||
...options,
|
||||
relativePathToWorkspaceRoot: node_path_1.posix.relative(node_path_1.posix.join('/', e2eRootPath), '/'),
|
||||
}),
|
||||
(0, schematics_1.move)(e2eRootPath),
|
||||
])),
|
||||
(0, standalone_1.addRootProvider)(relatedAppName, ({ code, external }) => code `${external('provideProtractorTestingSupport', '@angular/platform-browser')}()`),
|
||||
...E2E_DEV_DEPENDENCIES.map((name) => (0, dependency_1.addDependency)(name, latest_versions_1.latestVersions[name], {
|
||||
type: dependency_1.DependencyType.Dev,
|
||||
existing: dependency_1.ExistingBehavior.Skip,
|
||||
})),
|
||||
addScriptsToPackageJson(),
|
||||
]);
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AA6CH,4BAsDC;AAjGD,2DAUoC;AACpC,yCAA0C;AAC1C,sDAAwF;AACxF,oDAAgD;AAChD,gEAA4D;AAC5D,sDAAwD;AACxD,oDAAuD;AACvD,kEAAyE;AAGzE;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC;IACzC,YAAY;IACZ,uBAAuB;IACvB,SAAS;IACT,aAAa;CACd,CAAC,CAAC;AAEH,SAAS,uBAAuB;IAC9B,OAAO,CAAC,IAAI,EAAE,EAAE;QACd,MAAM,OAAO,GAAG,IAAI,oBAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QACnD,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAEzC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,mBAAyB,OAAmB;IAC1C,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IAEnC,OAAO,IAAA,2BAAe,EAAC,CAAC,SAAS,EAAE,EAAE;QACnC,MAAM,OAAO,G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,EAAE,EAAE,CACnC,IAAA,0BAAa,EAAC,IAAI,EAAE,gCAAc,CAAC,IAAI,CAAC,EAAE;gBACxC,IAAI,EAAE,2BAAc,CAAC,GAAG;gBACxB,QAAQ,EAAE,6BAAgB,CAAC,IAAI;aAChC,CAAC,CACH;YACD,uBAAuB,EAAE;SAC1B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Generates a new, generic end-to-end test definition in the given project.
|
||||
*/
|
||||
export type Schema = {
|
||||
/**
|
||||
* The name of the application being tested.
|
||||
*/
|
||||
relatedAppName: string;
|
||||
/**
|
||||
* The HTML selector for the root component of the test app.
|
||||
*/
|
||||
rootSelector?: string;
|
||||
};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
|
||||
// CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=schema.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"schema.js","sourceRoot":"","sources":["schema.ts"],"names":[],"mappings":";AACA,mFAAmF;AACnF,oFAAoF"}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"$id": "SchematicsAngularE2eApp",
|
||||
"title": "Angular e2e Application Options Schema",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"description": "Generates a new, generic end-to-end test definition in the given project.",
|
||||
"properties": {
|
||||
"rootSelector": {
|
||||
"description": "The HTML selector for the root component of the test app.",
|
||||
"type": "string",
|
||||
"default": "app-root"
|
||||
},
|
||||
"relatedAppName": {
|
||||
"description": "The name of the application being tested.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["relatedAppName"]
|
||||
}
|
||||
Reference in New Issue
Block a user