@nstudio/angular
Version:
Angular Plugin for xplat
96 lines (95 loc) • 4.88 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const schematics_1 = require("@angular-devkit/schematics");
const xplat_utils_1 = require("@nstudio/xplat-utils");
const testing_1 = require("@nstudio/xplat/testing");
const testing_2 = require("../../utils/testing");
(0, xplat_utils_1.setTest)();
xdescribe('helpers schematic', () => {
let appTree;
beforeEach(() => {
appTree = schematics_1.Tree.empty();
appTree = (0, testing_1.createXplatWithApps)(appTree);
});
it('applitools: should create all files', () => __awaiter(void 0, void 0, void 0, function* () {
// const optionsXplat: XPlatOptions = {
// npmScope: 'testing',
// prefix: 'tt',
// platforms: 'web,nativescript'
// };
// appTree = schematicRunner.runSchematic('xplat', optionsXplat, appTree);
const appOptions = {
name: 'foo',
prefix: 'tt',
e2eTestRunner: 'cypress',
useXplat: false,
};
// console.log('appTree:', appTree);
appTree = yield (0, testing_2.runSchematic)('app', appOptions, appTree);
const cypressJsonPath = '/apps/web-foo-e2e/cypress.json';
let fileContent = (0, testing_1.getFileContent)(appTree, cypressJsonPath);
let cypressJson = (0, xplat_utils_1.jsonParse)(fileContent);
expect(cypressJson.supportFile).toBe(false);
const options = {
name: 'applitools',
target: 'web-foo',
};
// console.log('appTree:', appTree);
const tree = yield (0, testing_2.runSchematic)('helpers', options, appTree);
const files = tree.files;
// console.log(files);
expect(files.indexOf('/apps/web-foo-e2e/src/support/index.ts')).toBeGreaterThanOrEqual(0);
expect(files.indexOf('/apps/web-foo-e2e/src/plugins/index.ts')).toBeGreaterThanOrEqual(0);
// modified testing files
let filePath = '/apps/web-foo-e2e/src/support/index.ts';
fileContent = (0, testing_1.getFileContent)(tree, filePath);
// console.log(fileContent);
expect(fileContent.indexOf('@applitools/eyes-cypress/commands')).toBeGreaterThanOrEqual(0);
filePath = '/apps/web-foo-e2e/src/plugins/index.ts';
fileContent = (0, testing_1.getFileContent)(tree, filePath);
// console.log(fileContent);
expect(fileContent.indexOf(`require('@applitools/eyes-cypress')(module);`)).toBeGreaterThanOrEqual(0);
fileContent = (0, testing_1.getFileContent)(tree, cypressJsonPath);
// console.log(fileContent);
cypressJson = (0, xplat_utils_1.jsonParse)(fileContent);
expect(cypressJson.supportFile).toBe(`./src/support/index.js`);
filePath = '/apps/web-foo-e2e/src/integration/app.spec.ts';
fileContent = (0, testing_1.getFileContent)(tree, filePath);
// console.log(fileContent);
expect(fileContent.indexOf(`eyesOpen`)).toBeGreaterThanOrEqual(0);
}));
it('applitools: should throw if target is missing', () => __awaiter(void 0, void 0, void 0, function* () {
// const optionsXplat: XPlatOptions = {
// npmScope: 'testing',
// prefix: 'tt',
// platforms: 'web,nativescript'
// };
// appTree = schematicRunner.runSchematic('xplat', optionsXplat, appTree);
const appOptions = {
name: 'foo',
prefix: 'tt',
e2eTestRunner: 'cypress',
useXplat: false,
};
// console.log('appTree:', appTree);
appTree = yield (0, testing_2.runSchematic)('app', appOptions, appTree);
const cypressJsonPath = '/apps/web-foo-e2e/cypress.json';
let fileContent = (0, testing_1.getFileContent)(appTree, cypressJsonPath);
let cypressJson = (0, xplat_utils_1.jsonParse)(fileContent);
expect(cypressJson.supportFile).toBe(false);
const options = {
name: 'applitools',
};
// console.log('appTree:', appTree);
yield expect((0, testing_2.runSchematic)('helpers', options, appTree)).rejects.toThrow(`The helper "applitools" requires the --target flag.`);
}));
});
;