I follow this tutorial
https://www.codetutorial.io/laravel-5-and-angular-2-beta-setup/
and this
https://laracasts.com/discuss/channels/laravel/angular2-laravel-hello-world-app
But I get that error:
Error: #http://localhost/naturedev/public/js/app.js:40:1
#http://localhost/naturedev/public/js/app.js:1:1
Zone</ZoneDelegate</ZoneDelegate.prototype.invoke#http://localhost/naturedev/public/js/angular2/bundles/angular2-polyfills.js:332:20
Zone</Zone</Zone.prototype.run#http://localhost/naturedev/public/js/angular2/bundles/angular2-polyfills.js:227:25
scheduleResolveOrReject/<#http://localhost/naturedev/public/js/angular2/bundles/angular2-polyfills.js:576:53
Zone</ZoneDelegate</ZoneDelegate.prototype.invokeTask#http://localhost/naturedev/public/js/angular2/bundles/angular2-polyfills.js:365:24
Zone</Zone</Zone.prototype.runTask#http://localhost/naturedev/public/js/angular2/bundles/angular2-polyfills.js:263:29
drainMicroTaskQueue#http://localhost/naturedev/public/js/angular2/bundles/angular2-polyfills.js:482:26
ZoneTask/this.invoke#http://localhost/naturedev/public/js/angular2/bundles/angular2-polyfills.js:434:22
Evaluating http://localhost/naturedev/public/js/app.js
Error loading http://localhost/naturedev/public/js/app.js
var newErr = new Error(newMsg, err.fileName, err.lineNumber);
This is how my gulp file look like:
var gulp = require("gulp");
var bower = require("gulp-bower");
var elixir = require("laravel-elixir");
var elixirTypscript = require('elixir-typescript');
elixir(function (mix) {
mix.copy('node_modules/angular2', 'public/js/angular2');
mix.copy('node_modules/rxjs', 'public/js/rxjs');
mix.copy('node_modules/systemjs', 'public/js/systemjs');
mix.copy('node_modules/es6-promise', 'public/js/es6-promise');
mix.copy('node_modules/es6-shim', 'public/js/es6-shim');
mix.copy('node_modules/zone.js/dist', 'public/js/zone.js/dist');
mix.typescript(
[
'app.component.ts',
'boot.ts'
],
'public/js',
{
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
}
);
});
Full code is just published here.
Gulp create app.js file from boot.ts and app.component.ts.
Can anybody help me?
Firstly, you need to open file node_modules\elixir-typescript\index.js:
Comment out this line ".pipe($.concat(paths.output.name))" : So the generated files won't be combine in to one single files. The two js files will be generated to "public/js" as your configuration.
I checked your code, you already had this: "///<reference path="../../../public/js/angular2/typings/browser.d.ts"/>" in boot.ts file. That's good.
Modify the file index.blade.php change System.import('js/app') to System.import('js/boot')
Modify the file app.component.ts, change selector: 'my-app' to selector: 'naturedev-app'. That is how you configured in index.blade.php, so we need to make them with the same name.
And the last one, you need to change the gulpfile.js configuration, find this:
mix.copy('node_modules/angular2', 'public/js/angular2');
mix.copy('node_modules/rxjs', 'public/js/rxjs');
mix.copy('node_modules/systemjs', 'public/js/systemjs');
mix.copy('node_modules/es6-promise', 'public/js/es6-promise');
mix.copy('node_modules/es6-shim', 'public/js/es6-shim');
And change to
mix.copy('node_modules/angular2', 'public/angular2');
mix.copy('node_modules/rxjs', 'public/rxjs');
mix.copy('node_modules/systemjs', 'public/systemjs');
mix.copy('node_modules/es6-promise', 'public/es6-promise');
mix.copy('node_modules/es6-shim', 'public/es6-shim');
The structure needs to be changed to match your configuration. This is a quick fix. If I have time I'll find another solution for you.
If you need to test Angular 2, Laravel 5.2. I think with those modifications you're ready to go.
I also committed changes to your GitHub.
Hope it helps you!
try to open firefox manually as root
go to its directory (eventully in your personal repository) and run it .firefox , this error will diseppear , and appearly its related to the user privileges relatively to node_modules , the problem isn't clear , but like that u may run normally your app
Related
I am trying to build a cypress BDD framework. I've think I've created the feature and step definition file correctly. When I run the the test with npx cypress run --spec cypress/integration/examples/shoppingCart.feature --headed --browser chrome, I get the following result here in this video , the vid is about 20sec long.
I wasn't sure what to think so I did another video that was a process of elimination and looking at the BDD set up. I'm still unsure (this one is about 8 mins long).
I will add the feature file, step definition file and error message.
I am totally puzzled.
Error message
`1) End to End shopping cart
User can purchase items and have them delivered to shipping address:
Error: Step implementation missing for: I am on the Ecommerce page
at Context.resolveAndRunStepDefinition (http://localhost:54824/__cypress/tests?p=cypress/integration/examples/shoppingCart.feature:12277:11)
at Context.eval (http://localhost:54824/__cypress/tests?p=cypress/integration/examples/shoppingCart.feature:11603:35)
`
Feature file
Scenario: User can purchase items and have them delivered to shipping address
Given I am on the Ecommerce page
When I add the mobile handsets to the shopping cart
And I verify the total price of shopping cart
Then I select the checkout button
When I will select my shipping location
And I agree to the terms and conditions checkbox
When I select the Purchase button
Then I will see an alert stating my order was successful, plus an ETA delivery
Step Definition file
/// <reference types="Cypress" />
import { Given,When,Then,And } from "cypress-cucumber-preprocessor/steps";
import Homepage from "../../../support/pageObjects/Homepage";
import orderSummaryPage from "../../../support/pageObjects/orderSummaryPage";
import completeOrderPage from "../../../support/pageObjects/completeOrderPage";
const homepage = new Homepage()
const StartCheckout = new orderSummaryPage()
const CompleteOrder = new completeOrderPage()
Given ( 'I am on the Ecommerce page', () => {
cy.visit(Cypress.env('url')+"/angularpractice/")
})
When('I add the mobile handsets to the shopping cart',function () {
homepage.getShopTab().click()
this.data.mobileHandset.forEach(function(element) {// this custom commad will add items to your cart
cy.AddToCart(element)
});
StartCheckout.getBasketCheckoutButton().click()
} )//end of step
And('I verify the total price of shopping cart',() => {
//calculate shopping cart here
let sum=0
CompleteOrder.getProductCost().each(($e1, index, $list) =>{
const unitCost=$e1.text()
let res= unitCost.split(" ")
res= res[1].trim()
sum=Number(sum)+Number(res)
}).then(function()
{
cy.log(sum)
})
CompleteOrder.getBasketTotalCost().then(function(element)
{
const shopCartTotal=element.text()
var res= shopCartTotal.split(" ")
var total= res[1].trim()
expect(Number(total)).to.equal(sum)
})
} )//end of step
Then('I select the checkout button',() => {
StartCheckout.getStartCheckoutButton().click()
} )//end of step
When('I will select my shipping location',() => {
CompleteOrder.getShippingCountry().type('United Kingdom')
CompleteOrder.getShippingCountryConfirm().click()
} )//end of step
And('I agree to the terms and conditions checkbox',()=> {
CompleteOrder.getTermsConditionsCheckbox().click({force: true})
})//end of step
When('I select the Purchase button',()=> {
CompleteOrder.getPurchaseButton().click()
})
Then('I will see an alert stating my order was successful, plus an ETA delivery',()=> {
CompleteOrder.getPurchaseAlert().then(function(element){
const actualText= element.text()
expect(actualText.includes('Success')).to.be.true
})
})
I'm sure I even created the BDD framework in the right place.
Update:
I was just asked about the non global step definitions in my package.json (I only copied from the 'script' section onwards).
Taking a quick look I don't even see it.
"scripts": {
"open": "cypress open",
"scripts": "cypress run",
"headTest": "cypress run --headed ",
"chromeTest": "cypress run --browser chrome",
"firefoxTest": "cypress run --browser firefox",
"edgeTest": "cypress run --browser edge",
"testDashboard": "cypress run --record --key 1642c226-ca7f-49c3-b513-da4ee9222ca8 --parallel",
"clean:reports": "rm -R -f cypress/reports && mkdir cypress/reports && mkdir cypress/reports/mochareports",
"pretest": "npm run clean:reports",
"combine-reports": "mochawesome-merge ./cypress/reports/mocha/*.json > cypress/reports/mochareports/report.json",
"generate-report": "marge cypress/reports/mochareports/report.json -f report -o cypress/reports/mochareports",
"posttest": "npm run combine-reports && npm run generate-report",
"test": "npm run scripts || npm run posttest"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"cypress": "^7.4.0",
"cypress-cucumber-preprocessor": "^4.1.3"
},
"dependencies": {
"cypress-multi-reporters": "^1.5.0",
"mocha": "^9.0.0",
"mochawesome": "^6.2.2",
"mochawesome-merge": "^4.2.0",
"mochawesome-report-generator": "^5.2.0",
"start-server-and-test": "^1.12.5"
}
}
Add the stepDefinitions option to the configuration,
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true,
"stepDefinitions": "cypress/integration/examples/BDD"
},
I set up your files and debugged through the source code.
Where should the step files be?
Basically, in loader.js this line
const stepDefinitionsToRequire = getStepDefinitionsPaths(filePath)
.map((sdPath) => `require('${sdPath}')`);
returns an empty array with your setup.
Digging into getStepDefinitionsPaths, and ignoring common steps for the moment, this line
let nonGlobalPath = getStepDefinitionPathsFrom(filePath);
is responsible for deciding where the steps files come from (filePath is the feature file full path).
and getStepDefinitionPathsFrom.js is just
return filePath.replace(path.extname(filePath), "")
which just removes the extension from
.../cypress/integration/examples/BDD/shoppingCart.feature
to give
.../cypress/integration/examples/BDD/shoppingCart
Then on this line nonGlobalPath is turned into a glob pattern to get all files of type .js, .ts, or .tsx
const nonGlobalPattern = `${nonGlobalPath}/**/*.+(js|ts|tsx)`;
which gives
.../cypress/integration/examples/BDD/shoppingCart/**/*.+(js|ts|tsx)
Conclusion: the step files must be in a folder with the same name as the feature file (in your case cypress/integration/examples/BDD/shoppingCart/) - except if you modify the commonPath setting (see below).
The step definition files can be named anything, as long as they have the correct extension. All files in that folder get searched for step definitions.
There is no need to move files up into the integration folder.
Fix #1
Create a new folder cypress/integration/examples/BDD/shoppingCart/ and move shoppingCartStepDef.js into it.
Config setting
stepDefinitions by itself has no effect on the steps location, but clearly it should from the documentation. This looks like a bug introduced by some change.
nonGlobalStepBaseDir affects the common steps path (which contains steps used across many features, e.g login), but not the path specific to the shoppingCart feature. Again, a bug due to the above problem.
commonPath seems to work as long as it points directly to the step definitions. The glob pattern **/*.+(js|ts|tsx) usage also has a bug - the pattern omits a trailing / which means the ** part (indicating any subfolder) is ineffective (See the difference between line 28 and the preceding line 26)
Fix #2
Set the commonPath config option to the folder containing the step definitions
"commonPath": "cypress/integration/examples/BDD/"
and you tests will work.
I was able to resolve this issue by doing the following:
I raised a ticket with the Developer as I noticed a NUMBER of people were all experiencing the same issue. The developer found they had a bug, fixed it and released a new version.
I had another issue after the new release and was able to fix that by:
I created a new folder under BDD called shopping cart. so it integrations/BDD/shoppingCart
Then I added the following to the package.json
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": false,
"stepDefinitions": "cypress/integration/BDD"
},
I think these changes will help. From your error I can tell is that the Feature file is not able to find your step definitions.
Change the name of the integration/examples to integration. Because of what I see from the cypress pre-processor plugins page, the tests are being searched under cypress/integration.
Again referring to the cypress pre-processor plugins page, the recommended way of writing a step definition file is that the steps definitions are searched from a directory with the same name as your .feature file.
So in your case, your .feature file is at cypress/integration/BDD/shoppingCart.feature. Now create a folder by the same name as the feature file inside the BDD folder cypress/integration/BDD/shoppingCart and inside that place your step definitions file there.
According to TheBrainFamily/cypress-cucumber-preprocessor/issues/596, use a folder matching the feature file
If the feature file is unable to read the .js script file then try to add the following in the package.json file.
When you define correct folder hierarchy then it will be able to detect and run the the script in the test runner of cypress. Like i have new folder with name "Drayxchange" so i added it like this below:
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": false,
"stepDefinitions": "cypress/integration/Drayxchange"
},
I am building a site using Visual Studio and WebCompiler is enabled.
When I compile on build my path files are changing to:
../../img/icons-#2x.png
rather than what the expected outcome is:
../img/icons-#2x.png
This is my current compilerconfig.json file:
[
{
"outputFile": "dist/css/style.css",
"inputFile": "styles/style.scss",
"sourceMap": false,
"relativeUrls": false
}
]
I've racked my brains/googled for hours but cannot figure out what is causing this to happen?
Just to note I resolved this issue by including the following in my compilerconfig.json:
"options": {
"sourceMap": false,
"relativeUrls": false
}
Following Protractor guide I wanted to create my first test. While the test works unfortunately JetBrains WebStorm does not recognize all of my variables in given test
I have enabled in Libraries/JavaScript:
jasmine
karma
karma-jasmine
HTML
Node.js Core
selenium-webdriver
As seen above Node.js Core library is enabled.
I have also visited this question but unfortunately the angular-protractor is no longer available.
What am I missing?
Your editor will understand it if its imported. Elese it will know where to find browser ot by
Add import statement at top of your file.
import {by, element} from 'protractor';
Use JS Hint RC. It will work like magic.
You can find this by going to
Settings -> Languages and Frameworks -> Javascript(select ECMA Script 6) ->Code Quality Tools- >JS Hint - Enable, use config file.
As for config file, save the bellow file, with following name: '.jshintrc'.
Rate the answer as positive if this worked for you!
{
"jasmine": true,
"mocha": true,
"esversion":6,
"loopfunc": true,
"node": true,
"globals": {
"esversion": 6,
"angular": false,
"browser": false,
"inject": false,
"_": false,
"driver": false,
"protractor": false,
"$": false,
"$$": false,
"element": false,
"by": false,
"list": false
}
}
I have a TypeScript project in Visual Studio, with modules installed via systemjs. I have the following code:
app.ts
import { Aurelia } from 'aurelia-framework';
For example, hovering Aurelia and pressing F12 (Go to Definition) opens up the correct aurelia-framework.d.ts file installed by systemjs. However, when I click Build, I get the following output:
error TS2307: Build: Cannot find module 'aurelia-router'.
Here is my tsconfig for reference.
tsconfig.json
{
"version": "1.8.0",
"compilerOptions": {
"rootDir": "src/",
"outDir": "dist/",
"target": "es5",
"module": "system",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
}
The answer appears to be to add a file - I call mine typings.d.ts - in the root of your aurelia app - /src or whatever you've called it - with a single /// reference to the index.d.ts file in your typings folder.
Then everything plays nice.
Here is a basic view of my "watch" grunt task:
module.exports = function(grunt){
require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks);
grunt.initConfig({
watch: {
options: {
livereload: true,
},
gruntfile:{
files:['gruntfile.js'],
tasks:['default']
},
html: {
files: ['index.html', 'assets/templates/*.html'],
tasks: ['default']
},
js: {
files: ['assets/js/*.js'],
tasks: ['default']
},
sass: {
options:{
livereload:false
},
files:['assets/sass/*.scss'],
tasks:['buildcss'],
},
css:{
files:['assets/sass/*.scss'],
tasks:[]
},
},
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['htmlhint','buildjs', 'buildcss', 'browserSync', 'watch','serve']);
};
So I have buildcss that compiles and minifies my scss into a master.css file. I've set up watch to watch the scss for changes, run the buildcss task, and then run the default task once the master.css file is updated. Then it should then refresh the page.
However, whenever I make a change to the scss file and save it, terminal shows no file updates even though it is apparently "watching files...". The only files that show as updated when I make changes are the html files: index and templates. It makes no sense to me. Sorry, I'm configuring Grunt for the first time here.
I was confusing watch and browserSync instead of using them together. First, I had to add watchTask: true, to browserSync, then I had to ensure that browserSync was being called before watch, and then I had to add the snippet of code the console prodded me to add to my index.html. Now it works perfectly. Here is the site I used to find my way: http://blog.teamtreehouse.com/getting-started-with-grunt